简体   繁体   English

iPhone SDK-presentMoviePlayerViewController无动画但有音频

[英]iPhone SDK - presentMoviePlayerViewControllerAnimated no video but audio

I'm trying to show a MPMoviePlayerViewController. 我正在尝试显示MPMoviePlayerViewController。

MPMoviePlayerViewController* theMoviePlayer = [[MPMoviePlayerViewController alloc]
                              initWithContentURL:[NSURL URLWithString:media_url]];

If I'm adding theMoviePlayer View to the current view via addSubview , everything is fine. 如果我要通过addSubview将MoviePlayer视图添加到当前视图,一切都很好。 But if I'm trying to show the player in a modal window, only the audio of the video is played back in the background. 但是,如果我要在模式窗口中显示播放器,则只会在后台播放视频的音频。 The view is not beeing displayed. 该视图未显示。

[self presentMoviePlayerViewControllerAnimated:theMoviePlayer]; 

I guessed you called presentMoviePlayerViewControllerAnimated in viewDidLoad and your view controller was not added to a navigation stack. 我猜想您在viewDidLoad中调用了presentMoviePlayerViewControllerAnimated,并且您的视图控制器未添加到导航堆栈中。

[self presentMoviePlayerViewControllerAnimated] will present MPMoviePlayerViewController as modal view and you can only present modal view controllers from controllers that have already been shown onscreen. [self presentMoviePlayerViewControllerAnimated]将MPMoviePlayerViewController呈现为模态视图,并且您只能从已经在屏幕上显示的控制器中呈现模态视图控制器。

So to fix it you can either <1> push your view controller into a navigation stack and call [self presentMoviePlayerViewControllerAnimated] after viewDidLoad 因此,要解决此问题,您可以<1>将视图控制器推入导航堆栈,并在viewDidLoad之后调用[self presentMoviePlayerViewControllerAnimated]

<2> Without a navigation stack you need to call [self presentMoviePlayerViewControllerAnimated] in the next run loop after viewDidLoad, eg with a IBAction or using dispatch_after <2>如果没有导航堆栈,则需要在viewDidLoad之后的下一个运行循环中调用[self presentMoviePlayerViewControllerAnimated],例如,使用IBAction或使用dispatch_after

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM