diff --git a/RELEASENOTES.md b/RELEASENOTES.md index bb679bccab..4540f9634c 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -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 diff --git a/library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java b/library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java index 59329088f8..f4467a180b 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/ForwardingPlayer.java @@ -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 { diff --git a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java index 45786b1eaa..277faca145 100644 --- a/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java +++ b/library/ui/src/main/java/com/google/android/exoplayer2/ui/StyledPlayerControlView.java @@ -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) {