我有一个场景,我希望用户能够从他之前离开的点开始播放视频。我目前正在使用MPMoviePlayerController。我可以使用MPMoviePlayerController的通知存储播放持续时间。
所以我需要的是每当用户启动相同的视频时,他都可以选择从他离开的时间开始。可能吗?如果是我怎么能这样做。我应该使用MPMoviePlayerController,因为我查看了文档中的所有方法,但没有找到任何内容。以下是我目前播放视频的代码。
- (void) playDownloadedFile:(NSString*) filePath
{
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:filePath]];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(movieDurationAvailableCallback:)
name:MPMovieDurationAvailableNotification
object:player];
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(moviePlaybackStateDidChangeCallback:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:player];
player.view.frame = CGRectMake(50, 25, 924, 718);
[self.view addSubview:player.view];
//---play movie---
[player play];
videoState = [[VideoState alloc] init];
}
- (void) movieDurationAvailableCallback:(NSNotification*) aNotification {
MPMoviePlayerController *moviePlayer = [aNotification object];
videoState.videoDuration = moviePlayer.duration;
}
- (void) moviePlaybackStateDidChangeCallback:(NSNotification*) aNotification {
MPMoviePlayerController *moviePlayer = [aNotification object];
videoState.playBackState = moviePlayer.playbackState;
}
答案 0 :(得分:2)
MPMoviePlayerController
有一个名为initialPlaybackTime
的属性。将其设置为从观看者停止的位置开始。