AVPlayerLayer as SCNMaterial is not displayed, sound plays normally

I am trying to use AVPlayerLayer as SCNMaterial to be assigned to SCNSphere.

Based on: https://developer.apple.com/library/mac/samplecode/SceneKit_Slides_WWDC2013/Listings/Scene_Kit_Session_WWDC_2013_Sources_Slides_ASCSlideMaterialLayer_m.html

I create a player, create a player layer and try with and without backgroundLayer to designate as material for my SCNSphere

The problem is that I get the same result reported here: SCNMaterialProperty not display layer

Play audio, video is not displayed at all!

The code bit is pretty simple:

    // video player
    let path = NSBundle.mainBundle().pathForResource("tb", ofType: "mp4")
    let url  = NSURL(fileURLWithPath: path!)
    let player = AVPlayer(URL: url)             // AVPlayer
    player.actionAtItemEnd = .None
    player.play()

    let frame = CGRectMake(0, 0, 300, 300)

    let playerLayer = AVPlayerLayer()
    playerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill
    playerLayer.frame = frame
    playerLayer.player = player


    sceneMaterial = SCNMaterial()
    sceneMaterial.specular.contents = UIColor.whiteColor()
    sceneMaterial.shininess = 0.5
    sceneMaterial.diffuse.contents = playerLayer
    sphere.materials = [sceneMaterial]

, backgroundLayer: CALayer playerLayer , .

+4
1

@Guig @Byron, SKVideoNode. sprikeKit + SceneKit, ,

+1

Source: https://habr.com/ru/post/1613659/


All Articles