MPMoviePlayerController problem at start

Posted by Infinity on Stack Overflow See other posts from Stack Overflow or by Infinity
Published on 2010-05-17T19:21:57Z Indexed on 2010/05/19 8:30 UTC
Read the original article Hit count: 350

Filed under:
|
|

Hello guys!

I have a problem with MPMoviePlayerController, because when I start it in fullscreen it exists, but the song is still playing. I added the MPMoviePlayerDidExitFullscreenNotification notification and it says that when the video starts playin it exists the full screen. Here's my code:

_multimediaPlayer = [[MPMoviePlayerController alloc] init];
_multimediaPlayer.controlStyle = MPMovieControlStyleDefault;
_multimediaPlayer.initialPlaybackTime = 0;

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(videoPlayBackDidFinish:) 
                                                 name:MPMoviePlayerPlaybackDidFinishNotification 
                                               object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(videoPlayerDidExitFullscreen:) 
                                                 name:MPMoviePlayerDidExitFullscreenNotification
                                               object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(videoPlayerPlaybackStateChanged:) 
                                                 name:MPMoviePlayerPlaybackStateDidChangeNotification
                                               object:nil];

    NSString *path = [NSString stringWithFormat:@"%@/mag_%d/%@", [FMUtils documentsFolderPathWithFile:nil], _magID, _pageObject.fileName];
    if ([FMUtils fileExistsAtPath:path]) {
        _multimediaPlayer.contentURL = [NSURL fileURLWithPath:path];
    } else {
        _multimediaPlayer.contentURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", self.dataURL, _pageObject.fileName]];
    }

    CGSize objectViewSize = self.frame.size;
    _multimediaPlayer.view.frame = CGRectMake(0, 0, objectViewSize.width, objectViewSize.height);
    [self addSubview:_multimediaPlayer.view];

    if (_pageObject.blink)  {
        [_multimediaPlayer setFullscreen:YES animated:YES];
    }

    [_multimediaPlayer play];

Most of the time it happens when the video is not downloaded and it needs to stream it.

Do you have any idea why is this happen?

© Stack Overflow or respective owner

Related posts about iphone-sdk-3.2

Related posts about objective-c