2

我对 Xcode 7.0 (7A220) 和 iOS 9.0 有疑问。AVPlayer我添加了一个带有and的视频(.mp4 或 mov,两者都不起作用)SKVideoNode。在带有 iOS 8.4 的模拟器上,它工作正常,但在 iOS 9.0(也是模拟器)上,视频没有显示。我可以听到音频。

GameScene(类SKScene)中的代码:

-(void)didMoveToView:(SKView *)view {

    NSURL *fileURL = [NSURL fileURLWithPath: [[NSBundle mainBundle] pathForResource:@"VideoName" ofType:@"mp4"]];
    _player = [AVPlayer playerWithURL: fileURL];

    _videoNode = [[SKVideoNode alloc] initWithAVPlayer:_player];
    _videoNode.size = CGSizeMake(200, 100);
    _videoNode.position = CGPointMake(200, 200);
    _videoNode.zPosition = 1000;

    [self addChild:_videoNode];

    _player.volume = 0.5;
    [_videoNode play];
}

UIViewController我有这个:

- (void)viewDidLoad
{
    [super viewDidLoad];

    // Configure the view.
    SKView * skView = (SKView *)self.view;
    skView.showsFPS = YES;
    skView.showsNodeCount = YES;

    /* Sprite Kit applies additional optimizations to improve rendering performance */
    // I have set this to NO, but it doesn't help
    skView.ignoresSiblingOrder = NO;

    // Create and configure the scene.
    CGRect rect = [[UIScreen mainScreen] bounds];
    GameScene *videoScene = [[GameScene alloc] initWithSize:rect.size];
    videoScene.scaleMode = SKSceneScaleModeAspectFill;

    GameScene *scene = [GameScene unarchiveFromFile:@"GameScene"];
    scene.scaleMode = SKSceneScaleModeAspectFill;

    // Present the scene.
    [skView presentScene:videoScene];
}

所以应用程序没有崩溃,视频正在播放(我能听到),但视频仅在 iOS 9 上不可见。有人有解决它的想法吗?

4

0 回答 0