Iphone 如何关闭电影播放器视图
嘿,我正在尝试制作一个iphone应用程序,你在UITableView中点击一个手机,它会显示你点击的任何东西的电影。到目前为止,我已经准备好了:Iphone 如何关闭电影播放器视图,iphone,cocoa-touch,mpmovieplayercontroller,media-player,Iphone,Cocoa Touch,Mpmovieplayercontroller,Media Player,嘿,我正在尝试制作一个iphone应用程序,你在UITableView中点击一个手机,它会显示你点击的任何东西的电影。到目前为止,我已经准备好了: 见多识广 单击单元格时加载nib文件 但我仍然需要帮助,让电影消失,当你点击“完成”时转到主nib文件 我尝试过使用这样的命名: MPMoviePlayerViewController* mpviewController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NS
MPMoviePlayerViewController* mpviewController = [[MPMoviePlayerViewController alloc]
initWithContentURL:[NSURL fileURLWithPath:movpath]];
[NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(leave) userInfo:nil repeats:NO];
这就是我在IOS 4.0上加载电影的方式
-(IBAction)PlayMovie
{
NSString *movpath = [[NSBundle mainBundle] pathForResource:@"Test" ofType:@"mov"];
MPMoviePlayerViewController* mpviewController = [[MPMoviePlayerViewController alloc]
initWithContentURL:[NSURL fileURLWithPath:movpath]];
[NSTimer scheduledTimerWithTimeInterval:4.0 target:self selector:@selector(leave) userInfo:nil repeats:NO];
[window addSubview:mpviewController.view];
[window makeKeyAndVisible];
MPMoviePlayerController *mp = [mpviewController moviePlayer];
[mp prepareToPlay];
mp.scalingMode = MPMovieScalingModeFill;
//[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayerDidExitFullscreen:)
// name:MPMoviePlayerDidExitFullscreenNotification
// object:mp];
[[mpviewController moviePlayer] play];
}
请帮忙
~Thank这是您应该使用的代码模板,它应该可以工作,并在电影播放结束后关闭您的电影
- (void)playMovie {
NSString *path = [[NSBundle mainBundle]
pathForResource:@"name" ofType:@"m4v"];
player = [[MPMoviePlayerViewController alloc]
initWithContentURL:[NSURL fileURLWithPath:path]];
[[NSNotificationCenter defaultCenter]
addObserver:self selector:@selector(movieFinishedPlaying:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:[player moviePlayer]];
[self presentMoviePlayerViewControllerAnimated:player];
}
-(void) movieFinishedPlaying: (NSNotification *) note {
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:[player moviePlayer]];
[player release];
}
我不知道这是有效的,还是被允许的。所以凹凸。:)