PanelSceneObject instancesExoPlayer for real-time channel mixingSpatialVideoSample project in Android Studio. Build the APK and deploy to your Meta Quest device using ADB or Meta Quest Developer Hub.| File / Scene | What it demonstrates | Key concepts |
|---|---|---|
SpatialVideoSampleActivity.kt | Main VR activity managing video playback, panel creation, and mode switching | AppSystemActivity, ExoPlayer setup, custom mesh/shader video panel, MR/VR state coordination |
SpatialAudioSystem.kt | Frame-by-frame spatial audio processing | Custom SystemBase, ECS queries for head tracking, stereo panning via channel mixing, distance-based attenuation |
MoviePanel.kt | Video library browser with thumbnails | Jetpack Compose ActivityPanelRegistration, stereo thumbnail extraction (left half crop), cross-activity communication |
MRPanel.kt | Passthrough mode toggle interface | Jetpack Compose IntentPanelRegistration, MR mode switching via activity callback |
res/layout/controls.xml | Playback controls with buttons and seek bar | XML-based LayoutXMLPanelRegistration, standard Android views in spatial UI |
spatial_video_sample_components.xml | Marker component for spatialized panels | Custom component definition, ECS tagging pattern |
PanelSceneObject with custom mesh geometry. Notice how MediaPanelRenderOptions specifies StereoMode.LeftRight with a 3840x1080 resolution for side-by-side eye images. ExoPlayer renders directly to the panel surface via panelSceneObject.getSurface(). See createVideoPanel() in SpatialVideoSampleActivity.kt for the mesh construction and shader assignment.SpatialAudioSystem that runs every frame. The system queries for the head entity via AvatarAttachment, calculates the direction to each SpatializedAudioPanel entity, and transforms it into head-local space to compute a panning angle. Audio levels follow a cosine-squared panning law that smoothly distributes sound between left and right channels based on angle. These gain values feed into a ChannelMixingAudioProcessor injected through a CustomRenderersFactory. See SpatialAudioSystem.kt for the computation logic.setMrMode() method. It also adjusts video panel position, scale, and control placement for each mode. See setMrMode() in SpatialVideoSampleActivity.kt for the complete transition logic.ActivityPanelRegistration with a Compose activity and ViewModel. The MR toggle uses IntentPanelRegistration with a simpler Compose activity. The playback controls use LayoutXMLPanelRegistration with a standard Android XML layout. Each approach serves different complexity needs. See registerPanels() in SpatialVideoSampleActivity.kt for all registration configurations.SpatialActivityManager. Notice how MoviePanel and MRPanel execute callbacks on the main activity using SpatialActivityManager.executeOnVrActivity<SpatialVideoSampleActivity> { activity -> ... }. This pattern safely bridges the process boundary between panel activities and the VR session, allowing video selection and mode toggles to trigger state changes in the main scene. See MoviePanel.kt and MRPanel.kt for usage examples.StereoMode to top-bottom layout or adjust the resolution for different video aspect ratios.IsdkGrabbable and IsdkPanelGrabHandle components.