1

很奇怪的bug!

好的,所以我正在使用 Sprite Kit 创建游戏。

启动时播放视频 (MPMoviePlayerController)

视频停止播放后,我将使用以下代码将其关闭...

- (void) moviePlayBackDidFinish:(NSNotification*)notification {

    _moviePlayer = [notification object];

    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                    name:MPMoviePlayerPlaybackDidFinishNotification
                                                  object:_moviePlayer];

    if ([_moviePlayer respondsToSelector:@selector(setFullscreen:animated:)])
    {

         _moviePlayer.fullscreen = NO;
        [_moviePlayer.view removeFromSuperview];


    }
}

一旦视频被删除,它就会显示游戏。

然而,一旦游戏出现,背景图像就会显得模糊或对比度低,但随后会在大约 2-3 秒后淡入以恢复正常。

我已经找到问题的原因了......

似乎当我设置

_moviePlayer.controlStyle = MPMovieControlStyleNone;

错误发生。但是当我设置

_moviePlayer.controlStyle = MPMovieControlStyleFullscreen;

没事!!

虽然我不想看到或有任何控制!..

有没有人遇到过这个/知道我该如何解决这个问题?

提前致谢

担。

4

1 回答 1

1

而不是MPMoviePlayerController你可以使用AVPlayer

NSString *resourcePath = [[NSBundle mainBundle] pathForResource:@"yourFileName" ofType:@"mp4"];
NSURL *videoURL = [NSURL fileURLWithPath:resourcePath];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:videoURL];
AVPlayer *player = [AVPlayer playerWithPlayerItem:playerItem];
SKVideoNode *introVideo = [[SKVideoNode alloc] initWithAVPlayer: player];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidReachEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:[player currentItem]];

和:

- (void)playerItemDidReachEnd:(NSNotification *)notification {
     // Remove AVPlayer, remove Observer...
}
于 2014-04-07T14:19:28.547 回答