androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.58k stars 376 forks source link

Video scaling issue on Android 7.0 in Media3 (version 1.4.0) #1664

Open Ioan1995 opened 4 weeks ago

Ioan1995 commented 4 weeks ago

Hello AndroidX.media3 team,

I've encountered an issue related to video scaling on a device running Android 7.0, using the Media3 library version 1.4.0.

In the demo application, I've added two buttons that scale the PlayerView to specific dimensions:

- scale(187, 684, 384, 216) – scaling to custom dimensions

`void scale(int x, int y, int w, int h) {
  Log.d("TEST", "scale to following coordinates[" + x + ", " + y + ", " + w + ", " + h + "].");
  if (playerView == null) {
    Log.d("TEST", "surfaceView is null, cannot scale the player.");
  } else {
    final ViewGroup.LayoutParams params = playerView.getLayoutParams();
    if (params == null) {
      Log.d("TEST", "surfaceView has no layoutParams, cannot scale the player.");
    } else {
      params.width = w == 0 ? ViewGroup.LayoutParams.MATCH_PARENT : w;
      params.height = h == 0 ? ViewGroup.LayoutParams.MATCH_PARENT : h;
      playerView.setX(x);
      playerView.setY(y);
      this.runOnUiThread(() -> {
        playerView.setLayoutParams(params);
      `});`
    }
  }
}`

The issue is as follows: while the PlayerView correctly changes its size and position, the video continues to play at its initial size (fullscreen) without adapting to the new layout. This problem occurs only on Android 7.0. On newer versions of Android (8.0, 11, 12), the scaling works as expected.

I also tried manually switching the video tracks to a lower resolution. This worked only if the player was not paused (i.e., exoPlayer.setPlayWhenReady(true); was set).

I've attached a log from the application and two video recordings to illustrate the issue:

A screen recording captured using Android Studio's screen recorder. A video recording captured using a phone, which shows the difference in behavior. scale.log

https://github.com/user-attachments/assets/1a360ac6-42c0-4457-b444-644137419f4f

https://github.com/user-attachments/assets/1cffb8c2-0e33-4344-b1f5-c040f6662743

oceanjules commented 1 week ago

What RESIZE_MODE are you using?