首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >奇怪的BUG,MPMovieControlStyleNone VS SpriteKit

奇怪的BUG,MPMovieControlStyleNone VS SpriteKit
EN

Stack Overflow用户
提问于 2014-04-06 18:35:27
回答 1查看 142关注 0票数 1

非常奇怪的bug!

好的,我用雪碧包创建了一个游戏。

启动时播放视频(MPMoviePlayerController)

一旦视频停止播放,我将使用以下代码来消除它……

代码语言:javascript
复制
- (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秒内看起来正常。

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

当我设置的时候

代码语言:javascript
复制
_moviePlayer.controlStyle = MPMovieControlStyleNone;

bug就发生了。但是当我设置

代码语言:javascript
复制
_moviePlayer.controlStyle = MPMovieControlStyleFullscreen;

很好!!

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

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

提前感谢

丹。

EN

回答 1

Stack Overflow用户

发布于 2014-04-07 22:19:29

您可以使用AVPlayer代替MPMoviePlayerController

代码语言:javascript
复制
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]];

和:

代码语言:javascript
复制
- (void)playerItemDidReachEnd:(NSNotification *)notification {
     // Remove AVPlayer, remove Observer...
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22892862

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档