ios - Using MPMoviePlayerController as texture in SceneKit -
i created cube in scenekit , tried use instance of mpmovieplayercontroller material. kind-ish works not well: video seems jumpy, jumping between video frames (basically replaying frames beginning till last point played). sound ok.
i made short screencapture of what's happening, guess obvious video: youtube vid
this code handles mapping cube , creation of player:
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 notification movie player sends whenever finishes playing */ nsnotificationcenter.defaultcenter().addobserver(self, selector: "videohasfinishedplaying:", name: mpmovieplayerplaybackdidfinishnotification, object: nil) println("successfully instantiated movie player") player.scalingmode = .aspectfit var materials = [scnmaterial]() 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 instantiate movie player") } }
any ideas how fix frame-jumping , why occurs? lot
i opened radar avplayerlayer not working scenekit texture (on device... works on simulator!). apple kind enough reply saying working intended, , supplied alternative:
avplayerlayer rendered out of process on device , can’t used texture. please use skvideonode instead.
Comments
Post a Comment