Skip to content

Commit

Permalink
Fix issue caused by using ForwardingPlayer and StyledPlayerControlView
Browse files Browse the repository at this point in the history
StyledPlayerControlView was checking whether the player is an ExoPlayer
instance to set the track selector. This means that, if apps were
wrapping an ExoPlayer in a ForwardingPlayer (to replace a
ControlDispatcher for example), the track selector wasn't set anymore.

PiperOrigin-RevId: 391776305
  • Loading branch information
kim-vde authored and christosts committed Sep 16, 2021
1 parent 64002f6 commit 4fd7d77
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release notes

### dev-v2 (not yet released)

* Core Library:
* Fix track selection in `StyledPlayerControlView` when using
`ForwardingPlayer`.

### 2.15.0 (2021-08-10)

* Core Library:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,11 @@ public void setDeviceMuted(boolean muted) {
player.setDeviceMuted(muted);
}

/** Returns the {@link Player} to which operations are forwarded. */
public Player getWrappedPlayer() {
return player;
}

@SuppressWarnings("deprecation") // Use of deprecated type for backwards compatibility.
private static class ForwardingEventListener implements EventListener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,9 @@ public void setPlayer(@Nullable Player player) {
if (player != null) {
player.addListener(componentListener);
}
if (player instanceof ForwardingPlayer) {
player = ((ForwardingPlayer) player).getWrappedPlayer();
}
if (player instanceof ExoPlayer) {
TrackSelector trackSelector = ((ExoPlayer) player).getTrackSelector();
if (trackSelector instanceof DefaultTrackSelector) {
Expand Down

0 comments on commit 4fd7d77

Please sign in to comment.