Benny
Benny

Reputation: 5092

MPMoviePlayer skip to time in movie

I'm using the MPMoviePlayer to play a movie. I want to be able to play the movie and allow the user to skip to a certain time in the film at the press of a button.

I'm setting the currentPlaybackTime property of the player but it doesn't seem to work. Instead it simply stats the movie from the beginning no matter what value I use.

Also I log the currentPlaybackTime property through a button click, it always returns a large number but it sometimes returns a minus value?! is this expected? (e.g. -227361412)

Sample code below:

- (IBAction) playShake 
{   
        NSLog(@"playback time = %d",playerIdle.currentPlaybackTime);    
        [self.playerIdle setCurrentPlaybackTime:2.0];
        return;
}

Upvotes: 2

Views: 2856

Answers (2)

Fireandlight27
Fireandlight27

Reputation: 716

I have successfully used this method of skipping to a point in a movie in the past. I suspect that your issue is actually with the video itself. When you set the currentPlaybackTime MPMoviePlayer will skip to the nearest keyframe in the video. If the video has few keyframes or you're only skipping forward a few seconds this could cause the video to start over from the beginning when you change the currentPlaybackTime.

Upvotes: 4

Grimless
Grimless

Reputation: 1266

-currentPlaybackTime returns a NSTimeInterval (double) which you are printing as a signed int. This will result in unexpected values. Try either casting to int (int)playerIdle.currentPlaybackTime or printing the double %1.3f.

Upvotes: 2

Related Questions