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.

#minor-release

PiperOrigin-RevId: 391776305
This commit is contained in:
kimvde 2021-08-19 17:27:18 +01:00 committed by bachinger
parent cbd6527926
commit 1ae879788a
3 changed files with 10 additions and 0 deletions

View file

@ -9,6 +9,8 @@
`com.google.android.exoplayer2.decoder.CryptoException`.
* Make `ExoPlayer.Builder` return a `SimpleExoPlayer` instance.
* Deprecate `SimpleExoPlayer.Builder`. Use `ExoPlayer.Builder` instead.
* Fix track selection in `StyledPlayerControlView` when using
`ForwardingPlayer`.
* Android 12 compatibility:
* Disable platform transcoding when playing content URIs on Android 12.
* Add `ExoPlayer.setVideoChangeFrameRateStrategy` to allow disabling of

View file

@ -619,6 +619,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 {

View file

@ -756,6 +756,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) {