mirror of
https://github.com/samsonjs/media.git
synced 2026-04-04 11:05:47 +00:00
Reset isLoading when calling SimpleBasePlayer.stop/release
isLoading is not allowed to be true when IDLE, so we have to set to false when stopping in case it was set to true before. PiperOrigin-RevId: 494975405
This commit is contained in:
parent
6e0f1f10b3
commit
e4f0b73aa3
2 changed files with 10 additions and 1 deletions
|
|
@ -2203,6 +2203,7 @@ public abstract class SimpleBasePlayer extends BasePlayer {
|
|||
.setTotalBufferedDurationMs(PositionSupplier.ZERO)
|
||||
.setContentBufferedPositionMs(state.contentPositionMsSupplier)
|
||||
.setAdBufferedPositionMs(state.adPositionMsSupplier)
|
||||
.setIsLoading(false)
|
||||
.build());
|
||||
}
|
||||
|
||||
|
|
@ -2234,6 +2235,7 @@ public abstract class SimpleBasePlayer extends BasePlayer {
|
|||
.setTotalBufferedDurationMs(PositionSupplier.ZERO)
|
||||
.setContentBufferedPositionMs(state.contentPositionMsSupplier)
|
||||
.setAdBufferedPositionMs(state.adPositionMsSupplier)
|
||||
.setIsLoading(false)
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2102,6 +2102,7 @@ public class SimpleBasePlayerTest {
|
|||
.setPlaylist(
|
||||
ImmutableList.of(
|
||||
new SimpleBasePlayer.MediaItemData.Builder(/* uid= */ new Object()).build()))
|
||||
.setIsLoading(true)
|
||||
.build();
|
||||
// Additionally set the repeat mode to see a difference between the placeholder and new state.
|
||||
State updatedState =
|
||||
|
|
@ -2109,6 +2110,7 @@ public class SimpleBasePlayerTest {
|
|||
.buildUpon()
|
||||
.setPlaybackState(Player.STATE_IDLE)
|
||||
.setRepeatMode(Player.REPEAT_MODE_ALL)
|
||||
.setIsLoading(false)
|
||||
.build();
|
||||
SettableFuture<?> future = SettableFuture.create();
|
||||
SimpleBasePlayer player =
|
||||
|
|
@ -2131,9 +2133,12 @@ public class SimpleBasePlayerTest {
|
|||
// Verify placeholder state and listener calls.
|
||||
assertThat(player.getPlaybackState()).isEqualTo(Player.STATE_IDLE);
|
||||
assertThat(player.getRepeatMode()).isEqualTo(Player.REPEAT_MODE_OFF);
|
||||
assertThat(player.isLoading()).isFalse();
|
||||
verify(listener).onPlaybackStateChanged(Player.STATE_IDLE);
|
||||
verify(listener)
|
||||
.onPlayerStateChanged(/* playWhenReady= */ false, /* playbackState= */ Player.STATE_IDLE);
|
||||
verify(listener).onIsLoadingChanged(false);
|
||||
verify(listener).onLoadingChanged(false);
|
||||
verifyNoMoreInteractions(listener);
|
||||
|
||||
future.set(null);
|
||||
|
|
@ -2218,6 +2223,7 @@ public class SimpleBasePlayerTest {
|
|||
.setPlaylist(
|
||||
ImmutableList.of(
|
||||
new SimpleBasePlayer.MediaItemData.Builder(/* uid= */ new Object()).build()))
|
||||
.setIsLoading(true)
|
||||
.build();
|
||||
// Additionally set the repeat mode to see a difference between the placeholder and new state.
|
||||
State updatedState = state.buildUpon().setRepeatMode(Player.REPEAT_MODE_ALL).build();
|
||||
|
|
@ -2239,8 +2245,9 @@ public class SimpleBasePlayerTest {
|
|||
|
||||
player.release();
|
||||
|
||||
// Verify initial change to IDLE without listener call.
|
||||
// Verify initial change to IDLE and !isLoading without listener call.
|
||||
assertThat(player.getPlaybackState()).isEqualTo(Player.STATE_IDLE);
|
||||
assertThat(player.isLoading()).isFalse();
|
||||
verifyNoMoreInteractions(listener);
|
||||
|
||||
future.set(null);
|
||||
|
|
|
|||
Loading…
Reference in a new issue