-
Notifications
You must be signed in to change notification settings - Fork 769
SurfaceView inside Compose AndroidView often shown stretched/cropped on API 34 #1237
Copy link
Copy link
Closed
Labels
Description
Version
Media3 main branch
More version details
1.3.0, 1.2.1, 1.1.1
Devices that reproduce the issue
Pixel running on Android 14 with updated to 5 March 2024 (important)
Devices that do not reproduce the issue
Pixel running on Android 14 without updated to 5 March 2024
Reproducible in the demo app?
Not tested
Reproduction steps
Here is code that could help to reproduce.
class MainActivity : ComponentActivity() {
@OptIn(UnstableApi::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val context = LocalContext.current
val exoPlayer = remember { ExoPlayer.Builder(context).build() }
DisposableEffect(Unit) {
onDispose {
exoPlayer.release()
}
}
Box(
modifier = Modifier
.fillMaxWidth()
.fillMaxHeight(0.5f) //important to have
// .height(500.dp) - also reproducible
.background(Color.Black),
contentAlignment = Alignment.Center
) {
AndroidView(
factory = { ctx ->
PlayerView(ctx).apply {
useController = false
resizeMode = AspectRatioFrameLayout.RESIZE_MODE_ZOOM
}
},
update = {
it.player = exoPlayer
exoPlayer.setMediaItem(
MediaItem.fromUri("https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4")
)
exoPlayer.playWhenReady = true
exoPlayer.prepare()
},
)
}
}
}
}
Expected result
Media should be visible correctly
Actual result
Media shows with a wrong aspect ratio
Media
Here is how it looks
Bug Report
- You will email the zip file produced by
adb bugreportto android-media-github@google.com after filing this issue.
Reactions are currently unavailable
