Commit 47919008 by olly Committed by kim-vde

Move Player.getTrackSelector to ExoPlayer

PiperOrigin-RevId: 353212567
parent ba803a2e
...@@ -151,6 +151,7 @@ ...@@ -151,6 +151,7 @@
* Add support for playing JPEG motion photos * Add support for playing JPEG motion photos
([#5405](https://github.com/google/ExoPlayer/issues/5405)). ([#5405](https://github.com/google/ExoPlayer/issues/5405)).
* Track selection: * Track selection:
* Moved `Player.getTrackSelector` to the `ExoPlayer` interface.
* Allow parallel adaptation for video and audio * Allow parallel adaptation for video and audio
([#5111](https://github.com/google/ExoPlayer/issues/5111)). ([#5111](https://github.com/google/ExoPlayer/issues/5111)).
* Simplified enabling tunneling with `DefaultTrackSelector`. * Simplified enabling tunneling with `DefaultTrackSelector`.
......
...@@ -33,7 +33,6 @@ import com.google.android.exoplayer2.source.TrackGroupArray; ...@@ -33,7 +33,6 @@ import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.trackselection.FixedTrackSelection; import com.google.android.exoplayer2.trackselection.FixedTrackSelection;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray; 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.Assertions;
import com.google.android.exoplayer2.util.Clock; import com.google.android.exoplayer2.util.Clock;
import com.google.android.exoplayer2.util.ListenerSet; import com.google.android.exoplayer2.util.ListenerSet;
...@@ -507,12 +506,6 @@ public final class CastPlayer extends BasePlayer { ...@@ -507,12 +506,6 @@ public final class CastPlayer extends BasePlayer {
} }
@Override @Override
@Nullable
public TrackSelector getTrackSelector() {
return null;
}
@Override
public void setRepeatMode(@RepeatMode int repeatMode) { public void setRepeatMode(@RepeatMode int repeatMode) {
if (remoteMediaClient == null) { if (remoteMediaClient == null) {
return; return;
......
/*
* 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.
*
* <p>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 {}
...@@ -449,7 +449,9 @@ public interface ExoPlayer extends Player { ...@@ -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 @Nullable
TrackSelector getTrackSelector(); TrackSelector getTrackSelector();
......
...@@ -34,7 +34,6 @@ import com.google.android.exoplayer2.source.TrackGroupArray; ...@@ -34,7 +34,6 @@ import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.text.Cue; import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.text.TextOutput; import com.google.android.exoplayer2.text.TextOutput;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray; 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.MutableFlags;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import com.google.android.exoplayer2.video.VideoFrameMetadataListener; import com.google.android.exoplayer2.video.VideoFrameMetadataListener;
...@@ -1380,12 +1379,6 @@ public interface Player { ...@@ -1380,12 +1379,6 @@ public interface Player {
*/ */
int getRendererType(int index); 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. */ /** Returns the available track groups. */
TrackGroupArray getCurrentTrackGroups(); TrackGroupArray getCurrentTrackGroups();
......
...@@ -83,7 +83,7 @@ import com.google.android.exoplayer2.util.Assertions; ...@@ -83,7 +83,7 @@ import com.google.android.exoplayer2.util.Assertions;
* thread. The track selector may call {@link InvalidationListener#onTrackSelectionsInvalidated()} * thread. The track selector may call {@link InvalidationListener#onTrackSelectionsInvalidated()}
* from any thread. * 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. * Notified when selections previously made by a {@link TrackSelector} are no longer valid.
......
...@@ -51,6 +51,7 @@ import androidx.recyclerview.widget.RecyclerView; ...@@ -51,6 +51,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.google.android.exoplayer2.C; import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ControlDispatcher; import com.google.android.exoplayer2.ControlDispatcher;
import com.google.android.exoplayer2.DefaultControlDispatcher; import com.google.android.exoplayer2.DefaultControlDispatcher;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo; import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.Format; import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.PlaybackPreparer; import com.google.android.exoplayer2.PlaybackPreparer;
...@@ -66,6 +67,7 @@ import com.google.android.exoplayer2.trackselection.DefaultTrackSelector.Selecti ...@@ -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.MappingTrackSelector.MappedTrackInfo;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray; 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.Assertions;
import com.google.android.exoplayer2.util.RepeatModeUtil; import com.google.android.exoplayer2.util.RepeatModeUtil;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
...@@ -759,8 +761,11 @@ public class StyledPlayerControlView extends FrameLayout { ...@@ -759,8 +761,11 @@ public class StyledPlayerControlView extends FrameLayout {
if (player != null) { if (player != null) {
player.addListener(componentListener); player.addListener(componentListener);
} }
if (player != null && player.getTrackSelector() instanceof DefaultTrackSelector) { if (player instanceof ExoPlayer) {
this.trackSelector = (DefaultTrackSelector) player.getTrackSelector(); TrackSelector trackSelector = ((ExoPlayer) player).getTrackSelector();
if (trackSelector instanceof DefaultTrackSelector) {
this.trackSelector = (DefaultTrackSelector) trackSelector;
}
} else { } else {
this.trackSelector = null; this.trackSelector = null;
} }
......
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