There is a system callback, which is called when real video duration is known:
MPMovieDurationAvailableNotification (iOS 3.2+)
This notification is posted when the duration of a movie object is determined. The object of the notification is the MPMoviePlayerController object itself. There is no userInfo dictionary. The duration value is reflected in the duration property of the movie player controller.However I couldn't make it work, even thought that would be the obvious place. Trying to reset player.endPlaybackTime at MPMovieDurationAvailableNotification callback didn't change anything on UI. There was still a few seconds of video "missing" when playback ended.
Since I couldn't change values at runtime, the next best thing is to do cleanup at finish (and hope that the user didn't pay attention to total playtime):
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerFinished:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:self.moviePlayer];
- (void)playerFinished:(NSNotification *)aNotification
{
MPMoviePlayerController *player =
[aNotification object];
// --- No effect
//player.endPlaybackTime =
// player.currentPlaybackTime;
// --- Restarts video
//player.currentPlaybackTime =
// player.endPlaybackTime;
// --- This works
player.currentPlaybackTime =
player.duration;
}
No comments:
Post a Comment