我正在编写一个简单的方法来启动一个流视频全屏,并让用户停止按下“完成”按钮。问题是,我不能删除MPMediaPlayerController视图,或者可能我做错了。
- (IBAction)playVideoButtonPressed:(id)sender {
NSURL *url = [NSURL URLWithString:@"http://mysite.com/video.mov"];
mp = [[MPMoviePlayerController alloc] initWithContentURL: url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayerPlaybackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
if ([mp respondsToSelector:@selector(setFullscreen:animated:)]) {
mp.controlStyle = MPMovieControlStyleFullscreen;
mp.shouldAutoplay = YES;
[self.view addSubview:mp.view];
[mp.view setTag:3];
[mp setFullscreen:YES animated:YES];
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:mp];
[mp play];
}
- (void)moviePlayBackDidFinish:(id)sender {
NSLog(@"Quitting MoviePlayer");
[mp.view removeFromSuperview];
}这个想法是,MPMediaPlayerController视图被称为点击应用程序中的一个按钮,当单击“完成”视频或视频结束时,该视图将被取消。
发布于 2011-10-31 22:35:40
我应该用MPMoviePlayerViewController的。
https://stackoverflow.com/questions/7833830
复制相似问题