Skip to content

[dependabot]: Bump exoplayer_version from 1.4.1 to 1.5.1 in /packages/video_player/video_player_android/android #8414

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ android {
}

dependencies {
def exoplayer_version = "1.4.1"
def exoplayer_version = "1.5.1"
implementation "androidx.media3:media3-exoplayer:${exoplayer_version}"
implementation "androidx.media3:media3-exoplayer-hls:${exoplayer_version}"
implementation "androidx.media3:media3-exoplayer-dash:${exoplayer_version}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

package io.flutter.plugins.videoplayer.texture;

import android.os.Build;
import androidx.annotation.NonNull;
import androidx.annotation.OptIn;
import androidx.media3.common.Format;
Expand Down Expand Up @@ -32,20 +31,7 @@ protected void sendInitialized() {
int width = videoSize.width;
int height = videoSize.height;
if (width != 0 && height != 0) {
if (Build.VERSION.SDK_INT <= 21) {
// On API 21 and below, Exoplayer may not internally handle rotation correction
// and reports it through VideoSize.unappliedRotationDegrees. We may apply it to
// fix the case of upside-down playback.
try {
RotationDegrees unappliedRotation =
RotationDegrees.fromDegrees(videoSize.unappliedRotationDegrees);
rotationCorrection = getRotationCorrectionFromUnappliedRotation(unappliedRotation);
} catch (IllegalArgumentException e) {
// Unapplied rotation other than 0, 90, 180, 270 reported by VideoSize. Because this is
// unexpected, we apply no rotation correction.
rotationCorrection = RotationDegrees.ROTATE_0;
}
} else if (surfaceProducerHandlesCropAndRotation) {
if (surfaceProducerHandlesCropAndRotation) {
// When the SurfaceTexture backend for Impeller is used, the preview should already
// be correctly rotated.
rotationCorrection = RotationDegrees.ROTATE_0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,13 @@ public class TextureExoPlayerEventListenerTest {

@Rule public MockitoRule initRule = MockitoJUnit.rule();

@Test
@Config(maxSdk = 21)
public void onPlaybackStateChangedReadySendInitialized_belowAndroid21() {
TextureExoPlayerEventListener eventListener =
new TextureExoPlayerEventListener(mockExoPlayer, mockCallbacks, true);
VideoSize size = new VideoSize(800, 400, 0, 0);
when(mockExoPlayer.getVideoSize()).thenReturn(size);
when(mockExoPlayer.getDuration()).thenReturn(10L);

eventListener.onPlaybackStateChanged(Player.STATE_READY);
verify(mockCallbacks).onInitialized(800, 400, 10L, 0);
}

@Test
@Config(minSdk = 22)
public void
onPlaybackStateChangedReadySendInitialized_whenSurfaceProducerHandlesCropAndRotation() {
TextureExoPlayerEventListener eventListener =
new TextureExoPlayerEventListener(mockExoPlayer, mockCallbacks, true);
VideoSize size = new VideoSize(800, 400, 0, 0);
VideoSize size = new VideoSize(800, 400, 0);
when(mockExoPlayer.getVideoSize()).thenReturn(size);
when(mockExoPlayer.getDuration()).thenReturn(10L);

Expand All @@ -68,7 +55,7 @@ public void onPlaybackStateChangedReadySendInitialized_belowAndroid21() {
onPlaybackStateChangedReadySendInitializedWithRotationCorrectionAndWidthAndHeightSwap_whenSurfaceProducerDoesNotHandleCropAndRotation() {
TextureExoPlayerEventListener eventListener =
new TextureExoPlayerEventListener(mockExoPlayer, mockCallbacks, false);
VideoSize size = new VideoSize(800, 400, 0, 0);
VideoSize size = new VideoSize(800, 400, 0);
int rotationCorrection = 90;
Format videoFormat = new Format.Builder().setRotationDegrees(rotationCorrection).build();

Expand All @@ -80,27 +67,13 @@ public void onPlaybackStateChangedReadySendInitialized_belowAndroid21() {
verify(mockCallbacks).onInitialized(800, 400, 10L, rotationCorrection);
}

@Test
@Config(maxSdk = 21)
public void
onPlaybackStateChangedReadyInPortraitMode90DegreesSwapWidthAndHeight_belowAndroid21() {
TextureExoPlayerEventListener eventListener =
new TextureExoPlayerEventListener(mockExoPlayer, mockCallbacks, true);
VideoSize size = new VideoSize(800, 400, 90, 0);
when(mockExoPlayer.getVideoSize()).thenReturn(size);
when(mockExoPlayer.getDuration()).thenReturn(10L);

eventListener.onPlaybackStateChanged(Player.STATE_READY);
verify(mockCallbacks).onInitialized(800, 400, 10L, 0);
}

@Test
@Config(minSdk = 22)
public void
onPlaybackStateChangedReadyInPortraitMode90DegreesDoesNotSwapWidthAndHeight_whenSurfaceProducerHandlesCropAndRotation() {
TextureExoPlayerEventListener eventListener =
new TextureExoPlayerEventListener(mockExoPlayer, mockCallbacks, true);
VideoSize size = new VideoSize(800, 400, 90, 0);
VideoSize size = new VideoSize(800, 400, 0);

when(mockExoPlayer.getVideoSize()).thenReturn(size);
when(mockExoPlayer.getDuration()).thenReturn(10L);
Expand All @@ -115,7 +88,7 @@ public void onPlaybackStateChangedReadySendInitialized_belowAndroid21() {
onPlaybackStateChangedReadyInPortraitMode90DegreesSwapWidthAndHeight_whenSurfaceProducerDoesNotHandleCropAndRotation() {
TextureExoPlayerEventListener eventListener =
new TextureExoPlayerEventListener(mockExoPlayer, mockCallbacks, false);
VideoSize size = new VideoSize(800, 400, 0, 0);
VideoSize size = new VideoSize(800, 400, 0);
int rotationCorrection = 90;
Format videoFormat = new Format.Builder().setRotationDegrees(rotationCorrection).build();

Expand All @@ -127,27 +100,13 @@ public void onPlaybackStateChangedReadySendInitialized_belowAndroid21() {
verify(mockCallbacks).onInitialized(800, 400, 10L, 90);
}

@Test
@Config(maxSdk = 21)
public void
onPlaybackStateChangedReadyInPortraitMode270DegreesSwapWidthAndHeight_belowAndroid21() {
TextureExoPlayerEventListener eventListener =
new TextureExoPlayerEventListener(mockExoPlayer, mockCallbacks, true);
VideoSize size = new VideoSize(800, 400, 270, 0);
when(mockExoPlayer.getVideoSize()).thenReturn(size);
when(mockExoPlayer.getDuration()).thenReturn(10L);

eventListener.onPlaybackStateChanged(Player.STATE_READY);
verify(mockCallbacks).onInitialized(800, 400, 10L, 0);
}

@Test
@Config(minSdk = 22)
public void
onPlaybackStateChangedReadyInPortraitMode270DegreesDoesNotSwapWidthAndHeight_whenSurfaceProducerHandlesCropAndRotation() {
TextureExoPlayerEventListener eventListener =
new TextureExoPlayerEventListener(mockExoPlayer, mockCallbacks, true);
VideoSize size = new VideoSize(800, 400, 270, 0);
VideoSize size = new VideoSize(800, 400, 0);
when(mockExoPlayer.getVideoSize()).thenReturn(size);
when(mockExoPlayer.getDuration()).thenReturn(10L);

Expand All @@ -161,7 +120,7 @@ public void onPlaybackStateChangedReadySendInitialized_belowAndroid21() {
onPlaybackStateChangedReadyInPortraitMode270DegreesDoesNotSwapWidthAndHeight_whenSurfaceProducerDoesNotHandleCropAndRotation() {
TextureExoPlayerEventListener eventListener =
new TextureExoPlayerEventListener(mockExoPlayer, mockCallbacks, false);
VideoSize size = new VideoSize(800, 400, 0, 0);
VideoSize size = new VideoSize(800, 400, 0);
int rotationCorrection = 270;
Format videoFormat = new Format.Builder().setRotationDegrees(rotationCorrection).build();

Expand All @@ -178,7 +137,7 @@ public void onPlaybackStateChangedReadySendInitialized_belowAndroid21() {
public void onPlaybackStateChangedReadyFlipped180DegreesInformEventHandler_belowAndroid21() {
TextureExoPlayerEventListener eventListener =
new TextureExoPlayerEventListener(mockExoPlayer, mockCallbacks, true);
VideoSize size = new VideoSize(800, 400, 180, 0);
VideoSize size = new VideoSize(800, 400, 0);
when(mockExoPlayer.getVideoSize()).thenReturn(size);
when(mockExoPlayer.getDuration()).thenReturn(10L);

Expand Down