我遇到Xcode 7.0(7A220)和iOS 9.0的问题。我使用AVPlayer
和SKVideoNode
添加了一个视频(.mp4或mov,两者都不起作用)。在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上是不可见的。有人有想法解决它吗?