@@ -24,22 +24,22 @@ import androidx.media3.common.C
24
24
import androidx.media3.common.MediaItem
25
25
import androidx.media3.exoplayer.ExoPlayer
26
26
import androidx.xr.runtime.Session
27
+ import androidx.xr.runtime.math.FloatSize2d
27
28
import androidx.xr.runtime.math.Pose
28
29
import androidx.xr.runtime.math.Vector3
29
30
import androidx.xr.scenecore.SurfaceEntity
30
31
import androidx.xr.scenecore.Texture
31
- import androidx.xr.scenecore.TextureSampler
32
32
import androidx.xr.scenecore.scene
33
33
import java.nio.file.Paths
34
34
import kotlinx.coroutines.launch
35
35
36
36
private fun ComponentActivity.surfaceEntityCreate (xrSession : Session ) {
37
37
// [START androidxr_scenecore_surfaceEntityCreate]
38
38
val stereoSurfaceEntity = SurfaceEntity .create(
39
- xrSession,
40
- SurfaceEntity .StereoMode .SIDE_BY_SIDE ,
41
- Pose (Vector3 (0.0f , 0.0f , - 1.5f )),
42
- SurfaceEntity .CanvasShape .Quad (1.0f , 1.0f )
39
+ session = xrSession,
40
+ stereoMode = SurfaceEntity .StereoMode .STEREO_MODE_SIDE_BY_SIDE ,
41
+ pose = Pose (Vector3 (0.0f , 0.0f , - 1.5f )),
42
+ shape = SurfaceEntity .Shape .Quad (FloatSize2d ( 1.0f , 1.0f ) )
43
43
)
44
44
val videoUri = Uri .Builder ()
45
45
.scheme(ContentResolver .SCHEME_ANDROID_RESOURCE )
@@ -60,13 +60,13 @@ private fun ComponentActivity.surfaceEntityCreateSbs(xrSession: Session) {
60
60
// Set up the surface for playing a 180° video on a hemisphere.
61
61
val hemisphereStereoSurfaceEntity =
62
62
SurfaceEntity .create(
63
- xrSession,
64
- SurfaceEntity .StereoMode .SIDE_BY_SIDE ,
65
- xrSession.scene.spatialUser.head?.transformPoseTo(
63
+ session = xrSession,
64
+ stereoMode = SurfaceEntity .StereoMode .STEREO_MODE_SIDE_BY_SIDE ,
65
+ pose = xrSession.scene.spatialUser.head?.transformPoseTo(
66
66
Pose .Identity ,
67
67
xrSession.scene.activitySpace
68
68
)!! ,
69
- SurfaceEntity .CanvasShape . Vr180Hemisphere (1.0f ),
69
+ shape = SurfaceEntity .Shape . Hemisphere (1.0f ),
70
70
)
71
71
// ... and use the surface for playing the media.
72
72
// [END androidxr_scenecore_surfaceEntityCreateSbs]
@@ -77,13 +77,13 @@ private fun ComponentActivity.surfaceEntityCreateTb(xrSession: Session) {
77
77
// Set up the surface for playing a 360° video on a sphere.
78
78
val sphereStereoSurfaceEntity =
79
79
SurfaceEntity .create(
80
- xrSession,
81
- SurfaceEntity .StereoMode .TOP_BOTTOM ,
82
- xrSession.scene.spatialUser.head?.transformPoseTo(
80
+ session = xrSession,
81
+ stereoMode = SurfaceEntity .StereoMode .STEREO_MODE_TOP_BOTTOM ,
82
+ pose = xrSession.scene.spatialUser.head?.transformPoseTo(
83
83
Pose .Identity ,
84
84
xrSession.scene.activitySpace
85
85
)!! ,
86
- SurfaceEntity .CanvasShape . Vr360Sphere (1.0f ),
86
+ shape = SurfaceEntity .Shape . Sphere (1.0f ),
87
87
)
88
88
// ... and use the surface for playing the media.
89
89
// [END androidxr_scenecore_surfaceEntityCreateTb]
@@ -93,10 +93,10 @@ private fun ComponentActivity.surfaceEntityCreateMVHEVC(xrSession: Session) {
93
93
// [START androidxr_scenecore_surfaceEntityCreateMVHEVC]
94
94
// Create the SurfaceEntity with the StereoMode corresponding to the MV-HEVC content
95
95
val stereoSurfaceEntity = SurfaceEntity .create(
96
- xrSession,
97
- SurfaceEntity .StereoMode .MULTIVIEW_LEFT_PRIMARY ,
98
- Pose (Vector3 (0.0f , 0.0f , - 1.5f )),
99
- SurfaceEntity .CanvasShape .Quad (1.0f , 1.0f )
96
+ session = xrSession,
97
+ stereoMode = SurfaceEntity .StereoMode .STEREO_MODE_MULTIVIEW_LEFT_PRIMARY ,
98
+ pose = Pose (Vector3 (0.0f , 0.0f , - 1.5f )),
99
+ shape = SurfaceEntity .Shape .Quad (FloatSize2d ( 1.0f , 1.0f ) )
100
100
)
101
101
val videoUri = Uri .Builder ()
102
102
.scheme(ContentResolver .SCHEME_ANDROID_RESOURCE )
@@ -123,10 +123,10 @@ private fun ComponentActivity.surfaceEntityCreateDRM(xrSession: Session) {
123
123
// Create the SurfaceEntity with the PROTECTED content security level.
124
124
val protectedSurfaceEntity = SurfaceEntity .create(
125
125
session = xrSession,
126
- stereoMode = SurfaceEntity .StereoMode .SIDE_BY_SIDE ,
126
+ stereoMode = SurfaceEntity .StereoMode .STEREO_MODE_SIDE_BY_SIDE ,
127
127
pose = Pose (Vector3 (0.0f , 0.0f , - 1.5f )),
128
- canvasShape = SurfaceEntity .CanvasShape .Quad (1.0f , 1.0f ),
129
- contentSecurityLevel = SurfaceEntity .ContentSecurityLevel . PROTECTED
128
+ shape = SurfaceEntity .Shape .Quad (FloatSize2d ( 1.0f , 1.0f ) ),
129
+ surfaceProtection = SurfaceEntity .SurfaceProtection . SURFACE_PROTECTION_PROTECTED
130
130
)
131
131
132
132
// Build a MediaItem with the necessary DRM configuration.
@@ -156,20 +156,20 @@ private fun ComponentActivity.surfaceEntityHDR(xrSession: Session) {
156
156
// Define the color properties for your HDR video. These values should be specific
157
157
// to your content.
158
158
val hdrMetadata = SurfaceEntity .ContentColorMetadata (
159
- colorSpace = SurfaceEntity .ContentColorMetadata .ColorSpace .BT2020 ,
160
- colorTransfer = SurfaceEntity .ContentColorMetadata .ColorTransfer .ST2084 , // PQ
161
- colorRange = SurfaceEntity .ContentColorMetadata .ColorRange .LIMITED ,
162
- maxCLL = 1000 // Example: 1000 nits
159
+ colorSpace = SurfaceEntity .ContentColorMetadata .ColorSpace .COLOR_SPACE_BT2020 ,
160
+ colorTransfer = SurfaceEntity .ContentColorMetadata .ColorTransfer .COLOR_TRANSFER_ST2084 , // PQ
161
+ colorRange = SurfaceEntity .ContentColorMetadata .ColorRange .COLOR_RANGE_LIMITED ,
162
+ maxContentLightLevel = 1000 // Example: 1000 nits
163
163
)
164
164
165
165
// Create a SurfaceEntity, passing the HDR metadata at creation time.
166
166
val hdrSurfaceEntity = SurfaceEntity .create(
167
167
session = xrSession,
168
- stereoMode = SurfaceEntity .StereoMode .MONO ,
168
+ stereoMode = SurfaceEntity .StereoMode .STEREO_MODE_MONO ,
169
169
pose = Pose (Vector3 (0.0f , 0.0f , - 1.5f )),
170
- canvasShape = SurfaceEntity .CanvasShape .Quad (1.0f , 1.0f ),
171
- contentColorMetadata = hdrMetadata
170
+ shape = SurfaceEntity .Shape .Quad (FloatSize2d (1.0f , 1.0f )),
172
171
)
172
+ hdrSurfaceEntity.contentColorMetadata = hdrMetadata
173
173
174
174
// Initialize ExoPlayer and set the surface.
175
175
val exoPlayer = ExoPlayer .Builder (this ).build()
@@ -195,8 +195,8 @@ private fun surfaceEntityEdgeFeathering(xrSession: Session) {
195
195
)
196
196
197
197
// Feather the edges of the surface.
198
- surfaceEntity.edgeFeather =
199
- SurfaceEntity .EdgeFeatheringParams .SmoothFeather (0.1f , 0.1f )
198
+ surfaceEntity.edgeFeatheringParams =
199
+ SurfaceEntity .EdgeFeatheringParams .RectangleFeather (0.1f , 0.1f )
200
200
// [END androidxr_scenecore_surfaceEntityEdgeFeathering]
201
201
}
202
202
@@ -214,7 +214,6 @@ private fun surfaceEntityAlphaMasking(xrSession: Session, activity: ComponentAct
214
214
Texture .create(
215
215
xrSession,
216
216
Paths .get(" textures" , " alpha_mask.png" ),
217
- TextureSampler .create()
218
217
)
219
218
220
219
// Apply the alpha mask.
0 commit comments