MPMoviePlayerController 5s后停止播放视频 [英] MPMoviePlayerController stops playing the video after 5s
本文介绍了MPMoviePlayerController 5s后停止播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试在iOS上播放视频,但是任何视频播放5s.这是我的代码:
I tried to play a video in iOS but it just played 5s for any video. This is my code:
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];
推荐答案
声明一个ivar @property (nonatomic,strong) MPMoviePlayerController *myMovieController;
按以下方式为其分配MoviPlayer,
assign theMoviPlayer to it as follows,
self.myMovieController = theMoviPlayer;
[self.view addSubview: self.myMovieController.view];
然后播放电影.
问题似乎是theMoviPlayer
没有保留.
这篇关于MPMoviePlayerController 5s后停止播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文