我正在尝试使用 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()