【发布时间】:2014-03-06 08:43:08
【问题描述】:
我尝试在 iOS 中播放视频,但任何视频都只能播放 5 秒。这是我的代码:
NSBundle *bundle = [NSBundle mainBundle];
NSString *moviePath = [bundle pathForResource:@"videoviewdemo" ofType:@"mp4"];
NSURL *movieURL = [[NSURL alloc]initFileURLWithPath:moviePath];
MPMoviePlayerController *theMoviPlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
theMoviPlayer.controlStyle = MPMovieControlStyleFullscreen;
theMoviPlayer.controlStyle = MPMovieControlStyleDefault;
[theMoviPlayer setMovieSourceType:MPMovieSourceTypeFile];
theMoviPlayer.shouldAutoplay = YES;
theMoviPlayer.view.transform = CGAffineTransformConcat(theMoviPlayer.view.transform, CGAffineTransformMakeRotation(M_PI_2));
[theMoviPlayer.view setFrame:self.view.frame];
[theMoviPlayer prepareToPlay];
[self.view addSubview:theMoviPlayer.view];
【问题讨论】:
-
但它只是播放了那是什么。你要说清楚。我标记了不清楚的问题
-
在prepareToPlay之后添加这行代码 - [theMoviPlayer Play];
标签: ios mpmovieplayercontroller