iOS视频播放代码
| [日期:2012-08-16] |
来源:Linux社区
作者:yhawaii |
[字体:大 中 小]
|
iOS视频播放代码
-
-
-
- -(void)playMovie:(NSString *)fileName{
NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:@"mp4"];
NSURL *url = [NSURL fileURLWithPath:path];
MPMoviePlayerController *movie = [[MPMoviePlayerController alloc] initWithContentURL:url];
movie.controlStyle = MPMovieControlStyleFullscreen;
[movie.view setFrame:self.view.bounds];
movie.initialPlaybackTime = -1;
[self.view addSubview:movie.view];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(myMovieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:movie];
[movie play];
}
#pragma mark -------------------视频播放结束委托--------------------
-(void)myMovieFinishedCallback:(NSNotification*)notify
{
MPMoviePlayerController* theMovie = [notify object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:theMovie];
[theMovie.view removeFromSuperview];
[theMovie release];
} 
评论声明
- 尊重网上道德,遵守中华人民共和国的各项有关法律法规
- 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
- 本站管理人员有权保留或删除其管辖留言中的任意内容
- 本站有权在网站内转载或引用您的评论
- 参与本评论即表明您已经阅读并接受上述条款
|
|
|
|