MPMoviePlayerController

MPMoviePlayerController

本文介绍了MPMoviePlayerController工作得很好,直到iOS 4.0现在只播放声音,没有视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 以下代码或多或少取自示例MPMoviePlayerController示例代码。在我去年写的一个应用程序中,它曾用于全屏播放视频而没有任何问题。从iOS 4.0开始,后台只有音频。这就像电影播放器​​没有视图或视图在我的应用程序后面。我仍然可以与我的应用互动,甚至开始一个新视频(仅限音频)。The code below is more or less taken from the example MPMoviePlayerController sample code. In an app I wrote last year, it used to play videos fullscreen without an issue. Since iOS 4.0, there's just audio in the background. It's like the movie player doesn't have a view or the view is behind my app. I can still interact with my app, even 'start' a new video (audio only).这就像电影播放器​​现在需要一个视图,但我不知道看看在API或示例代码中提供这种方式的任何方式(它看起来似乎是一个或两个版本。It's like the movie player now needs a view, but I don't see any way of supplying this in the API or the sample code (which does seem to be a version or two behind.我从URL加载我的视频,如果我将它们输入Safari,它们就可以正常播放。I load my videos from a URL and if I type these into Safari, they play just fine. 这是相关的代码片段,它的价值是什么:Here's the relevant code fragments, for what it's worth:- (void)playMovieUrl:(NSURL*)url delegate:(id)delegate callbackSelector:(SEL)selector{ @try { movieFinishedCallbackDelegate = delegate; movieFinishedCallbackSelector = selector; movieURL = url; MPMoviePlayerController* theMovie=[[MPMoviePlayerController alloc] initWithContentURL:url]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie]; [theMovie play]; } @catch (NSException * e) { return; }} // When the movie is done,release the controller. -(void)myMovieFinishedCallback:(NSNotification*)aNotification { MPMoviePlayerController* theMovie=[aNotification object]; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie]; [theMovie release]; [movieURL release]; [movieFinishedCallbackDelegate performSelector:movieFinishedCallbackSelector];} 推荐答案你可能需要展示电影:[self presentMoviePlayerViewControllerAnimated:theMovie];并改为: MPMoviePlayer 查看控制器MPMoviePlayerViewController 这篇关于MPMoviePlayerController工作得很好,直到iOS 4.0现在只播放声音,没有视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-19 02:00