Commit 4fd7d777 by kimvde Committed by Christos Tsilopoulos

Fix issue caused by using ForwardingPlayer and StyledPlayerControlView

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
parent 64002f6b
# 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:
......
......@@ -615,6 +615,11 @@ public class ForwardingPlayer implements Player {
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 {
......
......@@ -757,6 +757,9 @@ public class StyledPlayerControlView extends FrameLayout {
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) {
......
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