Adding Border Radius to a Video Integrated into a SceneKit Node

46 Views Asked by At

I attempted to add a border radius to a video and integrate it into a node.

My code functions properly only on the simulator; however, on a real device, the video does not appear but the sounds plays

func addMoviePreviewToNode() {
    guard let url = moviePreviewURL else { return }
    sceneView.isPlaying = true
    let player = AVPlayer(url: url)
    player.play()
    
    let playerLayer = AVPlayerLayer(player: player)
    playerLayer.masksToBounds = true
    playerLayer.cornerRadius = 50
    playerLayer.frame = CGRect(origin: .zero, size: movieSize)
    
    // The following line works on both simulator and real device, but lacks the desired border radius.
    // userWallpaperNode.geometry?.firstMaterial?.diffuse.contents = player
    
    // The line below works only on the simulator, but not on a real device, and includes the border radius.
    userWallpaperNode.geometry?.firstMaterial?.diffuse.contents = playerLayer
}

How can I solve this problem?

0

There are 0 best solutions below