我尝试在 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];
声明一个 ivar @property (nonatomic,strong) MPMoviePlayerController *myMovieController;
将MoviPlayer分配给它,如下所示,
self.myMovieController = theMoviPlayer;
[self.view addSubview: self.myMovieController.view];
然后播放电影。
问题似乎是 theMoviPlayer
没有保留。
关于ios - MPMoviePlayerController 5s 后停止播放视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22219227/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |