diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 65b81f2698..b32c6e5fd8 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -151,6 +151,7 @@ * Add support for playing JPEG motion photos ([#5405](https://github.com/google/ExoPlayer/issues/5405)). * Track selection: + * Moved `Player.getTrackSelector` to the `ExoPlayer` interface. * Allow parallel adaptation for video and audio ([#5111](https://github.com/google/ExoPlayer/issues/5111)). * Simplified enabling tunneling with `DefaultTrackSelector`. diff --git a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java index d4d7b4ae60..7ac24b4f8d 100644 --- a/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java +++ b/extensions/cast/src/main/java/com/google/android/exoplayer2/ext/cast/CastPlayer.java @@ -33,7 +33,6 @@ import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.trackselection.FixedTrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; -import com.google.android.exoplayer2.trackselection.TrackSelector; import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.Clock; import com.google.android.exoplayer2.util.ListenerSet; @@ -506,12 +505,6 @@ public final class CastPlayer extends BasePlayer { } } - @Override - @Nullable - public TrackSelector getTrackSelector() { - return null; - } - @Override public void setRepeatMode(@RepeatMode int repeatMode) { if (remoteMediaClient == null) { diff --git a/library/common/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelectorInterface.java b/library/common/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelectorInterface.java deleted file mode 100644 index abd4b32480..0000000000 --- a/library/common/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelectorInterface.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.android.exoplayer2.trackselection; - -// TODO(b/172315872) Replace @code by @link when Player has been migrated to common -/** - * The component of a {@code Player} responsible for selecting tracks to be played. - * - *

No Player agnostic track selection is currently supported. Clients should downcast to the - * implementation's track selection. - */ -// TODO(b/172315872) Define an interface for track selection. -public interface TrackSelectorInterface {} diff --git a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java index 047971bf85..9169271d12 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/ExoPlayer.java @@ -449,7 +449,9 @@ public interface ExoPlayer extends Player { } } - @Override + /** + * Returns the track selector that this player uses, or null if track selection is not supported. + */ @Nullable TrackSelector getTrackSelector(); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/Player.java b/library/core/src/main/java/com/google/android/exoplayer2/Player.java index 667d26e761..d88821ae2d 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/Player.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/Player.java @@ -34,7 +34,6 @@ import com.google.android.exoplayer2.source.TrackGroupArray; import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.TextOutput; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; -import com.google.android.exoplayer2.trackselection.TrackSelectorInterface; import com.google.android.exoplayer2.util.MutableFlags; import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.video.VideoFrameMetadataListener; @@ -1380,12 +1379,6 @@ public interface Player { */ int getRendererType(int index); - /** - * Returns the track selector that this player uses, or null if track selection is not supported. - */ - @Nullable - TrackSelectorInterface getTrackSelector(); - /** Returns the available track groups. */ TrackGroupArray getCurrentTrackGroups(); diff --git a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelector.java b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelector.java index f3d59d537e..59c5d5447b 100644 --- a/library/core/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelector.java +++ b/library/core/src/main/java/com/google/android/exoplayer2/trackselection/TrackSelector.java @@ -83,7 +83,7 @@ import com.google.android.exoplayer2.util.Assertions; * thread. The track selector may call {@link InvalidationListener#onTrackSelectionsInvalidated()} * from any thread. */ -public abstract class TrackSelector implements TrackSelectorInterface { +public abstract class TrackSelector { /** * Notified when selections previously made by a {@link TrackSelector} are no longer valid. 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 ea9f4508a3..464bb5a477 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 @@ -51,6 +51,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.ControlDispatcher; import com.google.android.exoplayer2.DefaultControlDispatcher; +import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.ExoPlayerLibraryInfo; import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.PlaybackPreparer; @@ -66,6 +67,7 @@ import com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Selecti import com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo; import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelectionArray; +import com.google.android.exoplayer2.trackselection.TrackSelector; import com.google.android.exoplayer2.util.Assertions; import com.google.android.exoplayer2.util.RepeatModeUtil; import com.google.android.exoplayer2.util.Util; @@ -759,8 +761,11 @@ public class StyledPlayerControlView extends FrameLayout { if (player != null) { player.addListener(componentListener); } - if (player != null && player.getTrackSelector() instanceof DefaultTrackSelector) { - this.trackSelector = (DefaultTrackSelector) player.getTrackSelector(); + if (player instanceof ExoPlayer) { + TrackSelector trackSelector = ((ExoPlayer) player).getTrackSelector(); + if (trackSelector instanceof DefaultTrackSelector) { + this.trackSelector = (DefaultTrackSelector) trackSelector; + } } else { this.trackSelector = null; }