Skip to content

Adding snippet for MV-HEVC video playback #513

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion xr/src/main/java/com/example/xr/scenecore/SpatialVideo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ private fun ComponentActivity.surfaceEntityCreate(xrSession: Session) {
val stereoSurfaceEntity = SurfaceEntity.create(
xrSession,
SurfaceEntity.StereoMode.SIDE_BY_SIDE,
// Position 1.5 meters in front of user
Pose(Vector3(0.0f, 0.0f, -1.5f)),
SurfaceEntity.CanvasShape.Quad(1.0f, 1.0f)
)
Expand Down Expand Up @@ -83,3 +82,26 @@ private fun ComponentActivity.surfaceEntityCreateTb(xrSession: Session) {
// ... and use the surface for playing the media.
// [END androidxr_scenecore_surfaceEntityCreateTb]
}

private fun ComponentActivity.surfaceEntityCreateMVHEVC(xrSession: Session) {
// [START androidxr_scenecore_surfaceEntityCreateMVHEVC]
// Create the SurfaceEntity with the StereoMode corresponding to the MV-HEVC content
val stereoSurfaceEntity = SurfaceEntity.create(
xrSession,
SurfaceEntity.StereoMode.MULTIVIEW_LEFT_PRIMARY,
Pose(Vector3(0.0f, 0.0f, -1.5f)),
SurfaceEntity.CanvasShape.Quad(1.0f, 1.0f)
)
val videoUri = Uri.Builder()
.scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
.path("mvhevc_video.mp4")
.build()
val mediaItem = MediaItem.fromUri(videoUri)

val exoPlayer = ExoPlayer.Builder(this).build()
exoPlayer.setVideoSurface(stereoSurfaceEntity.getSurface())
exoPlayer.setMediaItem(mediaItem)
exoPlayer.prepare()
exoPlayer.play()
// [END androidxr_scenecore_surfaceEntityCreateMVHEVC]
}