当设置为 MPMovieRepeatModeOne 时,MPMoviePlayer 不会重复
这个让我很困惑。如果有人有任何答案,我们将不胜感激。
我有以下方法,可以在应用程序的加载过程中播放视频:
-(void)playLoadingMovie
{
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"movie" ofType:@"mp4"];
movieController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]];
movieController.moviePlayer.repeatMode = MPMovieRepeatModeOne;
[movieController.moviePlayer setControlStyle:MPMovieControlStyleNone];
[movieController.view setFrame:CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width)];
[self.view addSubview:movieController.view];
NSLog(@"repeatMode: %d",movieController.moviePlayer.repeatMode);
}
所有内容都在代码中其他适当的位置和情况下正确声明、合成、发布等。这种特殊的方法工作得很好,只是它没有按应有的方式重复。
您可以看到,repeatMode 设置为 MPMovieRepeatModeOne,当我运行代码时,日志语句按预期打印出“repeatMode: 1”。
我知道我可以做一些黑客行为,并在电影结束时设置一个观察者,并让它调用一个方法来再次播放电影,但我更希望让这段代码正常工作。
有什么想法吗?
This one is baffling me. If anyone has any answers, they are appreciated.
I have the following method which plays a video during a loading process in my app:
-(void)playLoadingMovie
{
NSString *moviePath = [[NSBundle mainBundle] pathForResource:@"movie" ofType:@"mp4"];
movieController = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath]];
movieController.moviePlayer.repeatMode = MPMovieRepeatModeOne;
[movieController.moviePlayer setControlStyle:MPMovieControlStyleNone];
[movieController.view setFrame:CGRectMake(0, 0, self.view.frame.size.height, self.view.frame.size.width)];
[self.view addSubview:movieController.view];
NSLog(@"repeatMode: %d",movieController.moviePlayer.repeatMode);
}
Everything is properly declared, synthesized, released, etc... in the appropriate places and situations elsewhere in the code. This particular method works just fine, except for the fact that it does not repeat as it should.
You can see that the repeatMode is set to MPMovieRepeatModeOne, and when I run the code, the log statement prints out "repeatMode: 1" just as it should.
I know that I can do something hackish and set an observer for when the movie finishes and have it call a method to play the movie again, but I would much rather have this code work properly.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经发现它不重复的原因了。开始看电影后,我启动了许多内存密集型进程,不幸的是,对我来说,主线程上发生了太多事情,以至于当电影结束时,没有足够的内存可供重复。瘸。
所以代码没有任何问题。
现在,我将探索对某些进程使用其他线程,以便在主线程上为电影的重复腾出空间。
I have discovered the reason why it is not repeating. After I start the movie, I start a number of memory intensive processes, and unfortunately for me, I have so much happening on the main thread that when the movie finishes there isn't enough memory available for it to repeat. Lame.
So there is nothing wrong with the code.
Now I will be exploring using other threads for some of the processes in order to make room on the main thread for the movie to repeat.
这可能与您正在做的事情相同,但有时访问属性不起作用。您应该尝试 setRepeatMode。
This may just be the same thing you are doing but sometimes accessing properties dosen't work. You should try setRepeatMode.