`
374016526
  • 浏览: 96328 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

iphone播放本地视频

阅读更多

- (void)playPreviewVideo {
[UIApplication sharedApplication].statusBarHidden = YES;
NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"app" ofType:@"mp4"];
NSURL *url = [NSURL fileURLWithPath:urlStr];
if (!url) {
return;
}
MPMoviePlayerController *theMovie = [[MPMoviePlayerController alloc] init];
theMovie.view.backgroundColor = [UIColor blackColor];
theMovie.movieSourceType = MPMovieSourceTypeFile;
theMovie.scalingMode = MPMovieScalingModeAspectFill;
theMovie.controlStyle = MPMovieFinishReasonUserExited;
theMovie.view.frame = CGRectMake(0, 0, 480, 320);
[self.view addSubview:theMovie.view];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(myMovieFinishedCallback:) 
name:MPMoviePlayerPlaybackDidFinishNotification 
  object:theMovie];
[theMovie setContentURL:url];
[theMovie play];
}

- (void)myMovieFinishedCallback:(NSNotification *)aNotification {
MPMoviePlayerController *theMovie = [aNotification object];
[[NSNotificationCenter defaultCenter] removeObserver:self 
name:MPMoviePlayerPlaybackDidFinishNotification 
 object:theMovie];
[theMovie.view removeFromSuperview];
[theMovie release];
theMovie = nil;
[UIApplication sharedApplication].statusBarHidden = YES;
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics