SpatialGen Logo

SpatialGen

Back to blog
3 min read
Streaming Spatial - Window

How To: Spatial Video In A Window

We at SpatialGen have launched a free visionOS app which enables people to stream any spatial video in a window. The app will remain free so people can stream their own videos and developers can test their work. It supports 180/360 videos (in an immersive space), though we haven’t spent a lot of time on that functionality. We think of this app like a VLC for the Vision Pro.

SpatialGen Spatial Streaming - Dune 2 Clip

What’s The Problem?

Many developers have been asking about how to play spatial video within a window. This makes sense considering Apple’s Destination Video and documentation has been focussed on spatial video within an immersive space.

Unfortunately, many visionOS developers (us included) have fallen for this unintentional bait and worked on launching immersive spaces where a plane is overlaid with a video mesh. This introduces challenges such as plane transformation/orientation, window size matching, and more. Plus, we personally just dislike it.

The Solution

Displaying a spatial video within a window is actually very simple. All you need to do is create an AVPlayer() within a RealityView():

struct SpatialPlayerWindow: View {

   @EnvironmentObject var viewModel: PlayerViewModel

   var body: some View {
       RealityView { content in
           let player = AVPlayer(url: viewModel.videoURL!)
           player.play()
       }
   }
}

We were both overjoyed and annoyed at our wasted time when we discovered this. The idea of popping a player in a RealityView was an initial idea of ours, but we opted to follow Destination Video’s lead to our detriment.

If you want to stream spatial video for free, check out our free app, SpatialGen Spatial Streaming and make sure to create an account on SpatialGen.ai for all your spatial cloud needs! SpatialGen Spatial Streaming Homepage