Commit e4f0b73a by tonihei Committed by Ian Baker

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
parent 6e0f1f10
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment