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];
注意:这个方法在真机上测试没有问题,但是在模拟器上不能成功。

在iPhone开发中,使用MPMoviePlayerViewController初始化视频播放器,并通过videoURL加载内容。将播放器的视图添加到videoView上。虽然这种方法在真机上能正常设置音量,但在模拟器上可能无法奏效。
542

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



