-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[video_player_android] Correct rotation of videos recorded by the camera #7846
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
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5b8ad64
debugging
camsim99 bbac0c3
theoretical fix
camsim99 43898cb
Mild cleanup
camsim99 95d5e43
Undo extra import
camsim99 3306352
Fix logic + start tests
camsim99 3524885
Merge remote-tracking branch 'upstream/main' into vp_fix
camsim99 2664b51
Fix code + add tests
camsim99 1ba7efc
Remove print statement, bump version
camsim99 0ff09c6
Add Impeller case
camsim99 a374698
Merge remote-tracking branch 'upstream/main' into vp_fix
camsim99 a74cea9
Cleanup
camsim99 da92163
Add comment
camsim99 1a65eea
Correct changelog
camsim99 ee0f7de
Address review
camsim99 fc22ee6
Merge remote-tracking branch 'upstream/main' into vp_fix
camsim99 5f2a824
address review
camsim99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| import static org.mockito.Mockito.verifyNoMoreInteractions; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import androidx.media3.common.Format; | ||
| import androidx.media3.common.PlaybackException; | ||
| import androidx.media3.common.Player; | ||
| import androidx.media3.common.VideoSize; | ||
|
|
@@ -24,6 +25,7 @@ | |
| import org.mockito.junit.MockitoJUnit; | ||
| import org.mockito.junit.MockitoRule; | ||
| import org.robolectric.RobolectricTestRunner; | ||
| import org.robolectric.annotation.Config; | ||
|
|
||
| /** | ||
| * Unit tests for {@link ExoPlayerEventListener}. | ||
|
|
@@ -33,7 +35,7 @@ | |
| * ({@link VideoPlayerCallbacks} and/or interface with the player instance as expected. | ||
| */ | ||
| @RunWith(RobolectricTestRunner.class) | ||
| public final class ExoPlayerEventListenerTests { | ||
| public final class ExoPlayerEventListenerTest { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean to remove the "s" in tests?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes to make it consistent with the other tests in this plugin (and across plugins). |
||
| @Mock private ExoPlayer mockExoPlayer; | ||
| @Mock private VideoPlayerCallbacks mockCallbacks; | ||
| private ExoPlayerEventListener eventListener; | ||
|
|
@@ -46,7 +48,8 @@ public void setUp() { | |
| } | ||
|
|
||
| @Test | ||
| public void onPlaybackStateChangedReadySendInitialized() { | ||
| @Config(maxSdk = 28) | ||
| public void onPlaybackStateChangedReadySendInitialized_belowAndroid29() { | ||
| VideoSize size = new VideoSize(800, 400, 0, 0); | ||
| when(mockExoPlayer.getVideoSize()).thenReturn(size); | ||
| when(mockExoPlayer.getDuration()).thenReturn(10L); | ||
|
|
@@ -56,7 +59,25 @@ public void onPlaybackStateChangedReadySendInitialized() { | |
| } | ||
|
|
||
| @Test | ||
| public void onPlaybackStateChangedReadyInPortraitMode90DegreesSwapWidthAndHeight() { | ||
| @Config(minSdk = 29) | ||
| public void | ||
| onPlaybackStateChangedReadySendInitializedWithRotationCorrectionAndWidthAndHeightSwap_aboveAndroid29() { | ||
| VideoSize size = new VideoSize(800, 400, 0, 0); | ||
| int rotationCorrection = 90; | ||
| Format videoFormat = new Format.Builder().setRotationDegrees(rotationCorrection).build(); | ||
|
|
||
| when(mockExoPlayer.getVideoSize()).thenReturn(size); | ||
| when(mockExoPlayer.getDuration()).thenReturn(10L); | ||
| when(mockExoPlayer.getVideoFormat()).thenReturn(videoFormat); | ||
|
|
||
| eventListener.onPlaybackStateChanged(Player.STATE_READY); | ||
| verify(mockCallbacks).onInitialized(400, 800, 10L, rotationCorrection); | ||
| } | ||
|
|
||
| @Test | ||
| @Config(maxSdk = 21) | ||
| public void | ||
| onPlaybackStateChangedReadyInPortraitMode90DegreesSwapWidthAndHeight_belowAndroid21() { | ||
| VideoSize size = new VideoSize(800, 400, 90, 0); | ||
| when(mockExoPlayer.getVideoSize()).thenReturn(size); | ||
| when(mockExoPlayer.getDuration()).thenReturn(10L); | ||
|
|
@@ -66,7 +87,38 @@ public void onPlaybackStateChangedReadyInPortraitMode90DegreesSwapWidthAndHeight | |
| } | ||
|
|
||
| @Test | ||
| public void onPlaybackStateChangedReadyInPortraitMode270DegreesSwapWidthAndHeight() { | ||
| @Config(minSdk = 22, maxSdk = 28) | ||
| public void | ||
| onPlaybackStateChangedReadyInPortraitMode90DegreesDoesNotSwapWidthAndHeight_aboveAndroid21belowAndroid29() { | ||
| 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 = 29) | ||
| public void | ||
| onPlaybackStateChangedReadyInPortraitMode90DegreesSwapWidthAndHeight_aboveAndroid29() { | ||
| VideoSize size = new VideoSize(800, 400, 0, 0); | ||
| int rotationCorrection = 90; | ||
| Format videoFormat = new Format.Builder().setRotationDegrees(rotationCorrection).build(); | ||
|
|
||
| when(mockExoPlayer.getVideoSize()).thenReturn(size); | ||
| when(mockExoPlayer.getDuration()).thenReturn(10L); | ||
| when(mockExoPlayer.getVideoFormat()).thenReturn(videoFormat); | ||
|
|
||
| eventListener.onPlaybackStateChanged(Player.STATE_READY); | ||
| verify(mockCallbacks).onInitialized(400, 800, 10L, 90); | ||
| } | ||
|
|
||
| @Test | ||
| @Config(maxSdk = 21) | ||
| public void | ||
| onPlaybackStateChangedReadyInPortraitMode270DegreesSwapWidthAndHeight_belowAndroid21() { | ||
| VideoSize size = new VideoSize(800, 400, 270, 0); | ||
| when(mockExoPlayer.getVideoSize()).thenReturn(size); | ||
| when(mockExoPlayer.getDuration()).thenReturn(10L); | ||
|
|
@@ -76,7 +128,36 @@ public void onPlaybackStateChangedReadyInPortraitMode270DegreesSwapWidthAndHeigh | |
| } | ||
|
|
||
| @Test | ||
| public void onPlaybackStateChangedReadyFlipped180DegreesInformEventHandler() { | ||
| @Config(minSdk = 22, maxSdk = 28) | ||
| public void | ||
| onPlaybackStateChangedReadyInPortraitMode270DegreesDoesNotSwapWidthAndHeight_aboveAndroid21belowAndroid29() { | ||
| 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 = 29) | ||
| public void | ||
| onPlaybackStateChangedReadyInPortraitMode270DegreesSwapWidthAndHeight_aboveAndroid29() { | ||
| VideoSize size = new VideoSize(800, 400, 0, 0); | ||
| int rotationCorrection = 270; | ||
| Format videoFormat = new Format.Builder().setRotationDegrees(rotationCorrection).build(); | ||
|
|
||
| when(mockExoPlayer.getVideoSize()).thenReturn(size); | ||
| when(mockExoPlayer.getDuration()).thenReturn(10L); | ||
| when(mockExoPlayer.getVideoFormat()).thenReturn(videoFormat); | ||
|
|
||
| eventListener.onPlaybackStateChanged(Player.STATE_READY); | ||
| verify(mockCallbacks).onInitialized(400, 800, 10L, 270); | ||
| } | ||
|
|
||
| @Test | ||
| @Config(maxSdk = 21) | ||
| public void onPlaybackStateChangedReadyFlipped180DegreesInformEventHandler_belowAndroid21() { | ||
| VideoSize size = new VideoSize(800, 400, 180, 0); | ||
| when(mockExoPlayer.getVideoSize()).thenReturn(size); | ||
| when(mockExoPlayer.getDuration()).thenReturn(10L); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.