I have 360 videos in my Vimeo account and I am looking for a way to render it in my visionOS App.
I tried using this code to play video in 360 mode but unfortunately AVKit isn't supported in visionOS development.
//Create Entity for the video
let videoEntity = Entity()
//Search for video in paths
guard let url = Bundle.main.url(forResource: "example", withExtension: "mp4") else {fatalError("Video was not found!")}
//create a simple AVPlayer
let asset = AVURLAsset(url: url)
let playerItem = AVPlayerItem(asset: asset)
let player = AVPlayer()
//create a videoMaterial
let material = VideoMaterial(avPlayer: player)
//Made a Sphere with the videoEntity and asign the videoMaterial to it
videoEntity.components.set(ModelComponent(mesh: .generateSphere(radius: 1E3), materials: [material]))
//adjust the properties of the videoEntity(Sphere) if needed
videoEntity.scale = .init(x: 1, y: 1, z: -1)
videoEntity.transform.translation += SIMD3<Float>(0.0, 10.0, 0.0)
let angle = Angle.degrees(90)
let rotation = simd_quatf(angle: Float(angle.radians), axis: .init(x: 0, y: 0, z: 0))
videoEntity.transform.rotation = rotation
//add VideoEntity to realityView
content.add(videoEntity)
//start the VideoPlayer
player.replaceCurrentItem(with: playerItem)
player.play()
}
Is there a workaround to play 360 videos in visionOS or any SDK that handles it?
guard let url = Bundle.main.url(forResource: "example", withExtension: "mp4") else {fatalError("Video was not found!")}
Is for files in your project folder.
You need a direct link from Vimeo
https://help.vimeo.com/hc/en-us/articles/12426150952593-Direct-links-to-video-files
The you can download/play it in a VideoMaterial
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With