2010-09-20 68 views
0

下面的代码或多或少取自示例MPMoviePlayerController示例代码。在去年我写的一个应用程序中,它曾经全屏播放视频而没有问题。从iOS 4.0开始,只有背景音频。这就像电影播放器​​没有视图或视图在我的应用程序后面。我仍然可以与我的应用进行互动,甚至可以“开始”一个新视频(仅音频)。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]; 
} 

回答

0

你可能需要出示theMovie:

[self presentMoviePlayerViewControllerAnimated:theMovie]; 

,并切换到:

MPMoviePlayer 查看控制器

+0

是的,刚刚发现这一点。谢谢。 – edoloughlin 2010-09-20 10:35:38

0

在IOS 3.2字母使用MPMoviePlayerViewController。它表现得像一个modelViewcontroller

相关问题