NSURL *videoURL = [NSURL fileURLWithPath:selectedQuestion.GraphicsUrl];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
// Register to receive a notification that the movie is now in memory and ready to play
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePreloadDidFinish:)
name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
MPMoviePlayerController *moviePlayer = [videoPlayer moviePlayer];
[moviePlayer prepareToPlay];
[moviePlayer play];
videoPlayer.view.frame = imgQuestion.frame;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
// Register to receive a notification that the movie is now in memory and ready to play
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePreloadDidFinish:)
name:MPMoviePlayerLoadStateDidChangeNotification object:nil];
videoPlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL];
MPMoviePlayerController *moviePlayer = [videoPlayer moviePlayer];
[moviePlayer prepareToPlay];
[moviePlayer play];
videoPlayer.view.frame = imgQuestion.frame;
[videoView addSubview:videoPlayer.view];
注意:这个方法在真机上测试没有问题,但是在模拟器上不能成功。
iOS视频播放初始化
本文介绍了一个iOS应用中视频播放器的初始化过程,包括注册播放结束和预加载完成的通知、设置音量、准备并开始播放视频。
1829

被折叠的 条评论
为什么被折叠?



