【问题标题】:MPMoviePlayerController worked fine up to iOS 4.0 now just plays sound, no videoMPMoviePlayerController 在 iOS 4.0 之前运行良好,现在只播放声音,没有视频
【发布时间】:2010-09-21 14:32:39
【问题描述】:

下面的代码或多或少取自示例 MPMoviePlayerController 示例代码。在我去年编写的一个应用程序中,它曾经可以毫无问题地全屏播放视频。从 iOS 4.0 开始,背景中只有音频。就像电影播放器​​没有视图或视图在我的应用程序后面。我仍然可以与我的应用互动,甚至“开始”一个新视频(仅限音频)。

就像电影播放器​​现在需要一个视图,但我没有看到任何在 API 或示例代码中提供它的方式(这似乎是落后一两个版本。

我从一个 URL 加载我的视频,如果我在 Safari 中输入这些视频,它们就可以正常播放。

以下是相关的代码片段,值得一看:

- (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];
}

【问题讨论】:

    标签: iphone video ios4


    【解决方案1】:

    您可能需要展示这部电影:

    [self presentMoviePlayerViewControllerAnimated:theMovie];
    

    然后改为:

    MPMoviePlayer视图控制器

    【讨论】:

    • 是的,刚找到这个。谢谢。
    【解决方案2】:

    在 ios 3.2 字母中使用 MPMoviePlayerViewController。它的行为就像一个模型视图控制器

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-10
      • 1970-01-01
      • 2012-10-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多