tags:

views:

115

answers:

2

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).

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

You probably need to present theMovie:

[self presentMoviePlayerViewControllerAnimated:theMovie];

And change to:

MPMoviePlayerViewController

Larsaronen
Yeah, just found this. Thanks.
edoloughlin
A: 

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

pawan.mangal