Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
213 views
in Technique[技术] by (71.8m points)

mpmovieplayercontroller - Smooth video looping in iOS

Can anyone suggest a method by which you can achieve a completely smooth and seamless looping of a video clip in iOS? I have tried two methods, both of which produce a small pause when the video loops

1) AVPlayerLayer with the playerItemDidReachEnd notification setting off seekToTime:kCMTimeZero

I prefer to use an AVPlayerLayer (for other reasons), but this method produces a noticeable pause of around a second between loops.

2) MPMoviePlayerController with setRepeatMode:MPMovieRepeatModeOne

This results in a smaller pause, but it is still not perfect.

I'm not sure where to go from here. Can anyone suggest a soultion?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I can concur @SamBrodkin's findings.

[[NSNotificationCenter defaultCenter]
    addObserver: self
    selector: @selector(myMovieFinishedCallback:)
    name: MPMoviePlayerPlaybackStateDidChangeNotification
    object: m_player];

and

-(void) myMovieFinishedCallback: (NSNotification*) aNotification
{
    NSLog( @"myMovieFinishedCallback: %@", aNotification );
    MPMoviePlayerController *movieController = aNotification.object;
    NSLog( @"player.playbackState = %d", movieController.playbackState );
}

fixed the non-looping issue on iOS 5 for me too.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...