iphone 简单的iPhone播放器
1.http://www.cnblogs.com/KidReborn/archive/2010/10/07/1845097.html
-(void)openMovie:(id)sender { NSString *path = [[NSBundle mainBundle] pathForResource:@"movie" ofType:@"m4v"]; MPMoviePlayerController *movieController = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:path]]; //设置要播放的视频的位置 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:movieController]; //设置视频播放结束后的回调处理 [movieController play]; //播放视频 }
-(void)movieFinish:(NSNotification*)notification { MPMoviePlayerController *movieController = [notification object]; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:movieController]; [movieController release]; //释放资源 movieController = nil; [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:YES]; }
下载:demo