0

我正在尝试使用 SpriteKit 让视频出现在屏幕上,但看不到它。屏幕底部的 FPS 计数器更新为大约 60 FPS,这是有道理的。视频的音频也可以听到。删除改变 videoNode 位置的代码行没有任何作用。

guard let path = Bundle.main.path(forResource: "video", ofType: "mp4") else {
        fatalError("Video does not exist")
    }

    let url = URL(fileURLWithPath: path)

    let asset = AVURLAsset(url: url, options: nil)
    self.playerItem = AVPlayerItem(asset: asset)
    self.player = AVPlayer(playerItem: self.playerItem)

    videoNode = SKVideoNode(avPlayer: player!)
    videoNode?.position = CGPoint(x: self.frame.width / 2, y: self.frame.height / 2)
    self.addChild(self.videoNode!)

    videoNode?.play()
4

1 回答 1

0

奇怪的。在模拟器中运行应用程序将不允许显示视频。如果在实际测试设备上运行,视频显示正常。

于 2018-01-30T21:53:16.400 回答