开发者

MPMoviePlayerController worked fine up to iOS 4.0 now just plays sound, no video

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 ful开发者_StackOverflowlscreen 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).

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.

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


You probably need to present theMovie:

[self presentMoviePlayerViewControllerAnimated:theMovie];

And change to:

MPMoviePlayerViewController


in ios 3.2 letter use MPMoviePlayerViewController. it behave like a modelViewcontroller

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜