开发者

MPMoviePlayerController problem at start

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:) 
                                    开发者_StackOverflow中文版             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?


Problem solved while I not listen to MPMoviePlayerPlaybackStateDidChangeNotification.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜