【问题标题】:Strange BUG, MPMovieControlStyleNone VS SpriteKit奇怪的BUG,MPMovieControlStyleNone VS SpriteKit
【发布时间】:2014-04-06 10:35:26
【问题描述】:

很奇怪的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;

没关系!!

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

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

提前致谢

丹。

【问题讨论】:

    标签: video ios7 mpmovieplayercontroller sprite-kit mpmoviewcontroller


    【解决方案1】:

    您可以使用AVPlayer,而不是MPMoviePlayerController

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

    【讨论】:

    • 谢谢!没有完全按照我想要的方式工作,但它通过使用 SKVideoNode 引导我解决了问题!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-06
    • 1970-01-01
    • 1970-01-01
    • 2021-08-30
    相关资源
    最近更新 更多