After setting initialPlaybackTime property, the video(HTTP streaming) still plays from the beginning.
The same code works well in iOS <= 8.3:
self.moviePlayer.initialPlaybackTime = self.lastPlaybackTime;
[self.moviePlayer play];
This works for me, basically you need to setCurrentPlaybackTime when the movie starts playing, But you also need a flag playbackDurationSet which is set to NO when you present movieplayer and it is set to YES when the movie is seeked to the playbackDuration for the first time.
NOTE: this flag is required because when you seek the movie from the seek scrubber the moviePlayerPlaybackStateChanged is fired with playbackState of MPMoviePlaybackStatePlaying.
BOOL playbackDurationSet = NO;
- (void)moviePlayerPlaybackStateChanged:(NSNotification*)notification
{
MPMoviePlayerController* player = (MPMoviePlayerController*)notification.object;
switch ( player.playbackState ) {
case MPMoviePlaybackStatePlaying:
if(!playbackDurationSet){
[self.moviePlayer setCurrentPlaybackTime:yourStartTime];
playbackDurationSet = YES;
}
break;
}
}
- (void)moviePlayerPresented
{
playbackDurationSet = NO;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With