gpt4 book ai didi

ios - 在 SceneKit 中使用 MPMoviePlayerController 作为纹理

转载 作者:可可西里 更新时间:2023-11-01 00:16:39 26 4
gpt4 key购买 nike

我在 scenekit 中创建了一个立方体,并尝试使用 MPMoviePlayerController 的实例作为其 Material 。它有点好用但不是很好:视频似乎非常跳跃,就像它会在视频帧之间跳跃(基本上是从开始播放帧到播放的最后一个点)。声音还可以。

我对正在发生的事情进行了简短的截屏,我想从视频中可以明显看出:Youtube vid

这是处理立方体映射和玩家创建的代码:

var moviePlayer: MPMoviePlayerController?

func startPlayingVideo(){
let mainBundle = NSBundle.mainBundle()
let url = mainBundle.URLForResource("Sample", withExtension: "m4v")
moviePlayer = MPMoviePlayerController(contentURL: url)

if let player = moviePlayer{
/* Listen for the notification that the movie player sends us whenever it finishes playing */
NSNotificationCenter.defaultCenter().addObserver(self, selector: "videoHasFinishedPlaying:", name: MPMoviePlayerPlaybackDidFinishNotification, object: nil)
println("Successfully instantiated the movie player")
player.scalingMode = .AspectFit

var materials = [SCNMaterial]()
for i in 1...6 {
let material = SCNMaterial()
material.diffuse.contents = player.view.layer
player.view.frame = CGRectMake(0, 0, 200, 200)
materials.append(material)
}
boxGeometry.materials = materials

player.controlStyle = MPMovieControlStyle.None
player.play()
}
else {
println("Failed to instantiate the movie player")
}
}

关于如何解决此帧跳转及其发生原因的任何想法?非常感谢

最佳答案

我打开了一个radar关于 AVPlayerLayer 不作为 SceneKit 纹理工作(在设备上......在模拟器上工作!)。 Apple 很友善地回复说这是按预期工作的,并提供了一个替代方案:

AVPlayerLayer are rendered out of process on the device and can’t be used as a texture. Please use a SKVideoNode for this instead.

关于ios - 在 SceneKit 中使用 MPMoviePlayerController 作为纹理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29805632/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com