Remove deprecated Player track methods
getCurrentTrackGroups and getCurrentTrackSelections are retained for now, but moved from Player to ExoPlayer, to ease the transition for some application code that currently uses these methods. PiperOrigin-RevId: 430036355
This commit is contained in:
parent
3851ef3d69
commit
bdc3af1416
@ -34,17 +34,14 @@ import androidx.media3.common.DeviceInfo;
|
||||
import androidx.media3.common.MediaItem;
|
||||
import androidx.media3.common.MediaLibraryInfo;
|
||||
import androidx.media3.common.MediaMetadata;
|
||||
import androidx.media3.common.MimeTypes;
|
||||
import androidx.media3.common.PlaybackException;
|
||||
import androidx.media3.common.PlaybackParameters;
|
||||
import androidx.media3.common.Player;
|
||||
import androidx.media3.common.Timeline;
|
||||
import androidx.media3.common.TrackGroup;
|
||||
import androidx.media3.common.TrackGroupArray;
|
||||
import androidx.media3.common.TrackSelection;
|
||||
import androidx.media3.common.TrackSelectionArray;
|
||||
import androidx.media3.common.TrackSelectionParameters;
|
||||
import androidx.media3.common.TracksInfo;
|
||||
import androidx.media3.common.TracksInfo.TrackGroupInfo;
|
||||
import androidx.media3.common.VideoSize;
|
||||
import androidx.media3.common.text.Cue;
|
||||
import androidx.media3.common.util.Assertions;
|
||||
@ -68,7 +65,6 @@ import com.google.android.gms.common.api.PendingResult;
|
||||
import com.google.android.gms.common.api.ResultCallback;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.List;
|
||||
import org.checkerframework.checker.nullness.compatqual.NullableType;
|
||||
import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||
|
||||
/**
|
||||
@ -115,13 +111,10 @@ public final class CastPlayer extends BasePlayer {
|
||||
|
||||
private static final String TAG = "CastPlayer";
|
||||
|
||||
private static final int RENDERER_COUNT = 3;
|
||||
private static final int RENDERER_INDEX_VIDEO = 0;
|
||||
private static final int RENDERER_INDEX_AUDIO = 1;
|
||||
private static final int RENDERER_INDEX_TEXT = 2;
|
||||
private static final long PROGRESS_REPORT_PERIOD_MS = 1000;
|
||||
private static final TrackSelectionArray EMPTY_TRACK_SELECTION_ARRAY =
|
||||
new TrackSelectionArray(null, null, null);
|
||||
private static final long[] EMPTY_TRACK_ID_ARRAY = new long[0];
|
||||
|
||||
private final CastContext castContext;
|
||||
@ -146,8 +139,6 @@ public final class CastPlayer extends BasePlayer {
|
||||
private final StateHolder<PlaybackParameters> playbackParameters;
|
||||
@Nullable private RemoteMediaClient remoteMediaClient;
|
||||
private CastTimeline currentTimeline;
|
||||
private TrackGroupArray currentTrackGroups;
|
||||
private TrackSelectionArray currentTrackSelection;
|
||||
private TracksInfo currentTracksInfo;
|
||||
private Commands availableCommands;
|
||||
private @Player.State int playbackState;
|
||||
@ -224,8 +215,6 @@ public final class CastPlayer extends BasePlayer {
|
||||
playbackParameters = new StateHolder<>(PlaybackParameters.DEFAULT);
|
||||
playbackState = STATE_IDLE;
|
||||
currentTimeline = CastTimeline.EMPTY_CAST_TIMELINE;
|
||||
currentTrackGroups = TrackGroupArray.EMPTY;
|
||||
currentTrackSelection = EMPTY_TRACK_SELECTION_ARRAY;
|
||||
currentTracksInfo = TracksInfo.EMPTY;
|
||||
availableCommands = new Commands.Builder().addAll(PERMANENT_AVAILABLE_COMMANDS).build();
|
||||
pendingSeekWindowIndex = C.INDEX_UNSET;
|
||||
@ -557,16 +546,6 @@ public final class CastPlayer extends BasePlayer {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrackGroupArray getCurrentTrackGroups() {
|
||||
return currentTrackGroups;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrackSelectionArray getCurrentTrackSelections() {
|
||||
return currentTrackSelection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TracksInfo getCurrentTracksInfo() {
|
||||
return currentTracksInfo;
|
||||
@ -841,9 +820,6 @@ public final class CastPlayer extends BasePlayer {
|
||||
getCurrentMediaItem(), MEDIA_ITEM_TRANSITION_REASON_AUTO));
|
||||
}
|
||||
if (updateTracksAndSelectionsAndNotifyIfChanged()) {
|
||||
listeners.queueEvent(
|
||||
Player.EVENT_TRACKS_CHANGED,
|
||||
listener -> listener.onTracksChanged(currentTrackGroups, currentTrackSelection));
|
||||
listeners.queueEvent(
|
||||
Player.EVENT_TRACKS_CHANGED, listener -> listener.onTracksInfoChanged(currentTracksInfo));
|
||||
}
|
||||
@ -1000,55 +976,33 @@ public final class CastPlayer extends BasePlayer {
|
||||
return false;
|
||||
}
|
||||
|
||||
MediaStatus mediaStatus = getMediaStatus();
|
||||
MediaInfo mediaInfo = mediaStatus != null ? mediaStatus.getMediaInfo() : null;
|
||||
@Nullable MediaStatus mediaStatus = getMediaStatus();
|
||||
@Nullable MediaInfo mediaInfo = mediaStatus != null ? mediaStatus.getMediaInfo() : null;
|
||||
@Nullable
|
||||
List<MediaTrack> castMediaTracks = mediaInfo != null ? mediaInfo.getMediaTracks() : null;
|
||||
if (castMediaTracks == null || castMediaTracks.isEmpty()) {
|
||||
boolean hasChanged = !currentTrackGroups.isEmpty();
|
||||
currentTrackGroups = TrackGroupArray.EMPTY;
|
||||
currentTrackSelection = EMPTY_TRACK_SELECTION_ARRAY;
|
||||
boolean hasChanged = !TracksInfo.EMPTY.equals(currentTracksInfo);
|
||||
currentTracksInfo = TracksInfo.EMPTY;
|
||||
return hasChanged;
|
||||
}
|
||||
long[] activeTrackIds = mediaStatus.getActiveTrackIds();
|
||||
@Nullable long[] activeTrackIds = mediaStatus.getActiveTrackIds();
|
||||
if (activeTrackIds == null) {
|
||||
activeTrackIds = EMPTY_TRACK_ID_ARRAY;
|
||||
}
|
||||
|
||||
TrackGroup[] trackGroups = new TrackGroup[castMediaTracks.size()];
|
||||
@NullableType TrackSelection[] trackSelections = new TrackSelection[RENDERER_COUNT];
|
||||
TracksInfo.TrackGroupInfo[] trackGroupInfos =
|
||||
new TracksInfo.TrackGroupInfo[castMediaTracks.size()];
|
||||
TrackGroupInfo[] trackGroupInfos = new TrackGroupInfo[castMediaTracks.size()];
|
||||
for (int i = 0; i < castMediaTracks.size(); i++) {
|
||||
MediaTrack mediaTrack = castMediaTracks.get(i);
|
||||
trackGroups[i] =
|
||||
TrackGroup trackGroup =
|
||||
new TrackGroup(/* id= */ Integer.toString(i), CastUtils.mediaTrackToFormat(mediaTrack));
|
||||
|
||||
long id = mediaTrack.getId();
|
||||
@C.TrackType int trackType = MimeTypes.getTrackType(mediaTrack.getContentType());
|
||||
int rendererIndex = getRendererIndexForTrackType(trackType);
|
||||
boolean supported = rendererIndex != C.INDEX_UNSET;
|
||||
boolean selected =
|
||||
isTrackActive(id, activeTrackIds) && supported && trackSelections[rendererIndex] == null;
|
||||
if (selected) {
|
||||
trackSelections[rendererIndex] = new CastTrackSelection(trackGroups[i]);
|
||||
}
|
||||
@C.FormatSupport
|
||||
int[] trackSupport = new int[] {supported ? C.FORMAT_HANDLED : C.FORMAT_UNSUPPORTED_TYPE};
|
||||
final boolean[] trackSelected = new boolean[] {selected};
|
||||
@C.FormatSupport int[] trackSupport = new int[] {C.FORMAT_HANDLED};
|
||||
boolean[] trackSelected = new boolean[] {isTrackActive(mediaTrack.getId(), activeTrackIds)};
|
||||
trackGroupInfos[i] =
|
||||
new TracksInfo.TrackGroupInfo(
|
||||
trackGroups[i], /* adaptiveSupported= */ false, trackSupport, trackSelected);
|
||||
new TrackGroupInfo(
|
||||
trackGroup, /* adaptiveSupported= */ false, trackSupport, trackSelected);
|
||||
}
|
||||
TrackGroupArray newTrackGroups = new TrackGroupArray(trackGroups);
|
||||
TrackSelectionArray newTrackSelections = new TrackSelectionArray(trackSelections);
|
||||
TracksInfo newTracksInfo = new TracksInfo(ImmutableList.copyOf(trackGroupInfos));
|
||||
|
||||
if (!newTrackGroups.equals(currentTrackGroups)
|
||||
|| !newTrackSelections.equals(currentTrackSelection)
|
||||
|| !newTracksInfo.equals(currentTracksInfo)) {
|
||||
currentTrackSelection = newTrackSelections;
|
||||
currentTrackGroups = newTrackGroups;
|
||||
if (!newTracksInfo.equals(currentTracksInfo)) {
|
||||
currentTracksInfo = newTracksInfo;
|
||||
return true;
|
||||
}
|
||||
@ -1307,14 +1261,6 @@ public final class CastPlayer extends BasePlayer {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static int getRendererIndexForTrackType(@C.TrackType int trackType) {
|
||||
return trackType == C.TRACK_TYPE_VIDEO
|
||||
? RENDERER_INDEX_VIDEO
|
||||
: trackType == C.TRACK_TYPE_AUDIO
|
||||
? RENDERER_INDEX_AUDIO
|
||||
: trackType == C.TRACK_TYPE_TEXT ? RENDERER_INDEX_TEXT : C.INDEX_UNSET;
|
||||
}
|
||||
|
||||
private static int getCastRepeatMode(@RepeatMode int repeatMode) {
|
||||
switch (repeatMode) {
|
||||
case REPEAT_MODE_ONE:
|
||||
|
@ -1,98 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 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 androidx.media3.cast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.Format;
|
||||
import androidx.media3.common.TrackGroup;
|
||||
import androidx.media3.common.TrackSelection;
|
||||
import androidx.media3.common.util.Assertions;
|
||||
|
||||
/**
|
||||
* {@link TrackSelection} that only selects the first track of the provided {@link TrackGroup}.
|
||||
*
|
||||
* <p>This relies on {@link CastPlayer} track groups only having one track.
|
||||
*/
|
||||
/* package */ class CastTrackSelection implements TrackSelection {
|
||||
|
||||
private final TrackGroup trackGroup;
|
||||
|
||||
/**
|
||||
* @param trackGroup The {@link TrackGroup} from which the first track will only be selected.
|
||||
*/
|
||||
public CastTrackSelection(TrackGroup trackGroup) {
|
||||
this.trackGroup = trackGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return TYPE_UNSET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrackGroup getTrackGroup() {
|
||||
return trackGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Format getFormat(int index) {
|
||||
Assertions.checkArgument(index == 0);
|
||||
return trackGroup.getFormat(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndexInTrackGroup(int index) {
|
||||
return index == 0 ? 0 : C.INDEX_UNSET;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("ReferenceEquality")
|
||||
public int indexOf(Format format) {
|
||||
return format == trackGroup.getFormat(0) ? 0 : C.INDEX_UNSET;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(int indexInTrackGroup) {
|
||||
return indexInTrackGroup == 0 ? 0 : C.INDEX_UNSET;
|
||||
}
|
||||
|
||||
// Object overrides.
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return System.identityHashCode(trackGroup);
|
||||
}
|
||||
|
||||
// Track groups are compared by identity not value, as distinct groups may have the same value.
|
||||
@Override
|
||||
@SuppressWarnings({"ReferenceEquality", "EqualsGetClass"})
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
CastTrackSelection other = (CastTrackSelection) obj;
|
||||
return trackGroup == other.trackGroup;
|
||||
}
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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 androidx.media3.cast;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import androidx.media3.common.C;
|
||||
import androidx.media3.common.Format;
|
||||
import androidx.media3.common.TrackGroup;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/** Test for {@link CastTrackSelection}. */
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class CastTrackSelectionTest {
|
||||
|
||||
private static final TrackGroup TRACK_GROUP =
|
||||
new TrackGroup(new Format.Builder().build(), new Format.Builder().build());
|
||||
|
||||
private static final CastTrackSelection SELECTION = new CastTrackSelection(TRACK_GROUP);
|
||||
|
||||
@Test
|
||||
public void length_isOne() {
|
||||
assertThat(SELECTION.length()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTrackGroup_returnsSameGroup() {
|
||||
assertThat(SELECTION.getTrackGroup()).isSameInstanceAs(TRACK_GROUP);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getFormatSelectedTrack_isFirstTrack() {
|
||||
assertThat(SELECTION.getFormat(0)).isSameInstanceAs(TRACK_GROUP.getFormat(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIndexInTrackGroup_ofSelectedTrack_returnsFirstTrack() {
|
||||
assertThat(SELECTION.getIndexInTrackGroup(0)).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getIndexInTrackGroup_onePastTheEnd_returnsIndexUnset() {
|
||||
assertThat(SELECTION.getIndexInTrackGroup(1)).isEqualTo(C.INDEX_UNSET);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void indexOf_selectedTrack_returnsFirstTrack() {
|
||||
assertThat(SELECTION.indexOf(0)).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void indexOf_onePastTheEnd_returnsIndexUnset() {
|
||||
assertThat(SELECTION.indexOf(1)).isEqualTo(C.INDEX_UNSET);
|
||||
}
|
||||
|
||||
@Test(expected = Exception.class)
|
||||
public void getFormat_outOfBound_throws() {
|
||||
CastTrackSelection selection = new CastTrackSelection(TRACK_GROUP);
|
||||
|
||||
selection.getFormat(1);
|
||||
}
|
||||
}
|
@ -442,22 +442,6 @@ public class ForwardingPlayer implements Player {
|
||||
player.release();
|
||||
}
|
||||
|
||||
/** Calls {@link Player#getCurrentTrackGroups()} on the delegate and returns the result. */
|
||||
@SuppressWarnings("deprecation") // Forwarding to deprecated method
|
||||
@Deprecated
|
||||
@Override
|
||||
public TrackGroupArray getCurrentTrackGroups() {
|
||||
return player.getCurrentTrackGroups();
|
||||
}
|
||||
|
||||
/** Calls {@link Player#getCurrentTrackSelections()} on the delegate and returns the result. */
|
||||
@SuppressWarnings("deprecation") // Forwarding to deprecated method
|
||||
@Deprecated
|
||||
@Override
|
||||
public TrackSelectionArray getCurrentTrackSelections() {
|
||||
return player.getCurrentTrackSelections();
|
||||
}
|
||||
|
||||
/** Calls {@link Player#getCurrentTracksInfo()} on the delegate and returns the result. */
|
||||
@Override
|
||||
public TracksInfo getCurrentTracksInfo() {
|
||||
@ -846,12 +830,6 @@ public class ForwardingPlayer implements Player {
|
||||
listener.onMediaItemTransition(mediaItem, reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
|
||||
listener.onTracksChanged(trackGroups, trackSelections);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTracksInfoChanged(TracksInfo tracksInfo) {
|
||||
listener.onTracksInfoChanged(tracksInfo);
|
||||
|
@ -670,24 +670,6 @@ public interface Player {
|
||||
default void onMediaItemTransition(
|
||||
@Nullable MediaItem mediaItem, @MediaItemTransitionReason int reason) {}
|
||||
|
||||
/**
|
||||
* Called when the available or selected tracks change.
|
||||
*
|
||||
* <p>{@link #onEvents(Player, Events)} will also be called to report this event along with
|
||||
* other events that happen in the same {@link Looper} message queue iteration.
|
||||
*
|
||||
* @param trackGroups The available tracks. Never null, but may be of length zero.
|
||||
* @param trackSelections The selected tracks. Never null, but may contain null elements. A
|
||||
* concrete implementation may include null elements if it has a fixed number of renderer
|
||||
* components, wishes to report a TrackSelection for each of them, and has one or more
|
||||
* renderer components that is not assigned any selected tracks.
|
||||
* @deprecated Use {@link #onTracksInfoChanged(TracksInfo)} instead.
|
||||
*/
|
||||
@UnstableApi
|
||||
@Deprecated
|
||||
default void onTracksChanged(
|
||||
TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {}
|
||||
|
||||
/**
|
||||
* Called when the available or selected tracks change.
|
||||
*
|
||||
@ -2105,33 +2087,9 @@ public interface Player {
|
||||
void release();
|
||||
|
||||
/**
|
||||
* Returns the available track groups.
|
||||
* Returns information about the current tracks.
|
||||
*
|
||||
* @see Listener#onTracksChanged(TrackGroupArray, TrackSelectionArray)
|
||||
* @deprecated Use {@link #getCurrentTracksInfo()}.
|
||||
*/
|
||||
@UnstableApi
|
||||
@Deprecated
|
||||
TrackGroupArray getCurrentTrackGroups();
|
||||
|
||||
/**
|
||||
* Returns the current track selections.
|
||||
*
|
||||
* <p>A concrete implementation may include null elements if it has a fixed number of renderer
|
||||
* components, wishes to report a TrackSelection for each of them, and has one or more renderer
|
||||
* components that is not assigned any selected tracks.
|
||||
*
|
||||
* @see Listener#onTracksChanged(TrackGroupArray, TrackSelectionArray)
|
||||
* @deprecated Use {@link #getCurrentTracksInfo()}.
|
||||
*/
|
||||
@UnstableApi
|
||||
@Deprecated
|
||||
TrackSelectionArray getCurrentTrackSelections();
|
||||
|
||||
/**
|
||||
* Returns the available tracks, as well as the tracks' support, type, and selection status.
|
||||
*
|
||||
* @see Listener#onTracksChanged(TrackGroupArray, TrackSelectionArray)
|
||||
* @see Listener#onTracksInfoChanged(TracksInfo)
|
||||
*/
|
||||
TracksInfo getCurrentTracksInfo();
|
||||
|
||||
|
@ -38,6 +38,9 @@ import androidx.media3.common.MediaItem;
|
||||
import androidx.media3.common.Player;
|
||||
import androidx.media3.common.PriorityTaskManager;
|
||||
import androidx.media3.common.Timeline;
|
||||
import androidx.media3.common.TrackGroupArray;
|
||||
import androidx.media3.common.TrackSelectionArray;
|
||||
import androidx.media3.common.TracksInfo;
|
||||
import androidx.media3.common.VideoSize;
|
||||
import androidx.media3.common.text.Cue;
|
||||
import androidx.media3.common.util.Clock;
|
||||
@ -1191,6 +1194,27 @@ public interface ExoPlayer extends Player {
|
||||
@Nullable
|
||||
TrackSelector getTrackSelector();
|
||||
|
||||
/**
|
||||
* Returns the available track groups.
|
||||
*
|
||||
* @see Listener#onTracksInfoChanged(TracksInfo)
|
||||
* @deprecated Use {@link #getCurrentTracksInfo()}.
|
||||
*/
|
||||
@UnstableApi
|
||||
@Deprecated
|
||||
TrackGroupArray getCurrentTrackGroups();
|
||||
|
||||
/**
|
||||
* Returns the current track selections for each renderer, which may include {@code null} elements
|
||||
* if some renderers do not have any selected tracks.
|
||||
*
|
||||
* @see Listener#onTracksInfoChanged(TracksInfo)
|
||||
* @deprecated Use {@link #getCurrentTracksInfo()}.
|
||||
*/
|
||||
@UnstableApi
|
||||
@Deprecated
|
||||
TrackSelectionArray getCurrentTrackSelections();
|
||||
|
||||
/** Returns the {@link Looper} associated with the playback thread. */
|
||||
@UnstableApi
|
||||
Looper getPlaybackLooper();
|
||||
|
@ -1891,11 +1891,6 @@ import java.util.concurrent.TimeoutException;
|
||||
}
|
||||
if (previousPlaybackInfo.trackSelectorResult != newPlaybackInfo.trackSelectorResult) {
|
||||
trackSelector.onSelectionActivated(newPlaybackInfo.trackSelectorResult.info);
|
||||
TrackSelectionArray newSelection =
|
||||
new TrackSelectionArray(newPlaybackInfo.trackSelectorResult.selections);
|
||||
listeners.queueEvent(
|
||||
Player.EVENT_TRACKS_CHANGED,
|
||||
listener -> listener.onTracksChanged(newPlaybackInfo.trackGroups, newSelection));
|
||||
listeners.queueEvent(
|
||||
Player.EVENT_TRACKS_CHANGED,
|
||||
listener -> listener.onTracksInfoChanged(newPlaybackInfo.trackSelectorResult.tracksInfo));
|
||||
|
@ -38,8 +38,6 @@ import androidx.media3.common.Player.PlaybackSuppressionReason;
|
||||
import androidx.media3.common.Timeline;
|
||||
import androidx.media3.common.Timeline.Period;
|
||||
import androidx.media3.common.Timeline.Window;
|
||||
import androidx.media3.common.TrackGroupArray;
|
||||
import androidx.media3.common.TrackSelectionArray;
|
||||
import androidx.media3.common.TrackSelectionParameters;
|
||||
import androidx.media3.common.TracksInfo;
|
||||
import androidx.media3.common.VideoSize;
|
||||
@ -484,13 +482,6 @@ public class DefaultAnalyticsCollector implements AnalyticsCollector {
|
||||
listener -> listener.onMediaItemTransition(eventTime, mediaItem, reason));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") // Implementing deprecated method.
|
||||
@Override
|
||||
public final void onTracksChanged(
|
||||
TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
|
||||
// Do nothing. Handled by non-deprecated onTracksInfoChanged.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTracksInfoChanged(TracksInfo tracksInfo) {
|
||||
EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime();
|
||||
|
@ -109,8 +109,8 @@ import androidx.media3.common.Timeline;
|
||||
import androidx.media3.common.Timeline.Window;
|
||||
import androidx.media3.common.TrackGroup;
|
||||
import androidx.media3.common.TrackGroupArray;
|
||||
import androidx.media3.common.TrackSelectionArray;
|
||||
import androidx.media3.common.TracksInfo;
|
||||
import androidx.media3.common.TracksInfo.TrackGroupInfo;
|
||||
import androidx.media3.common.util.Assertions;
|
||||
import androidx.media3.common.util.Clock;
|
||||
import androidx.media3.common.util.Util;
|
||||
@ -277,8 +277,15 @@ public final class ExoPlayerTest {
|
||||
argThat(noUid(timeline)), eq(Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE));
|
||||
inOrder
|
||||
.verify(mockListener)
|
||||
.onTracksChanged(
|
||||
eq(new TrackGroupArray(new TrackGroup(ExoPlayerTestRunner.VIDEO_FORMAT))), any());
|
||||
.onTracksInfoChanged(
|
||||
eq(
|
||||
new TracksInfo(
|
||||
ImmutableList.of(
|
||||
new TrackGroupInfo(
|
||||
new TrackGroup(ExoPlayerTestRunner.VIDEO_FORMAT),
|
||||
/* adaptiveSupported= */ false,
|
||||
new int[] {C.FORMAT_HANDLED},
|
||||
/* tracksSelected= */ new boolean[] {true})))));
|
||||
inOrder.verify(mockListener, never()).onPositionDiscontinuity(anyInt());
|
||||
inOrder.verify(mockListener, never()).onPositionDiscontinuity(any(), any(), anyInt());
|
||||
assertThat(renderer.getFormatsRead()).containsExactly(ExoPlayerTestRunner.VIDEO_FORMAT);
|
||||
@ -649,8 +656,15 @@ public final class ExoPlayerTest {
|
||||
argThat(noUid(thirdTimeline)), eq(Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE));
|
||||
inOrder
|
||||
.verify(mockPlayerListener)
|
||||
.onTracksChanged(
|
||||
eq(new TrackGroupArray(new TrackGroup(ExoPlayerTestRunner.VIDEO_FORMAT))), any());
|
||||
.onTracksInfoChanged(
|
||||
eq(
|
||||
new TracksInfo(
|
||||
ImmutableList.of(
|
||||
new TrackGroupInfo(
|
||||
new TrackGroup(ExoPlayerTestRunner.VIDEO_FORMAT),
|
||||
/* adaptiveSupported= */ false,
|
||||
new int[] {C.FORMAT_HANDLED},
|
||||
/* tracksSelected= */ new boolean[] {true})))));
|
||||
assertThat(renderer.isEnded).isTrue();
|
||||
}
|
||||
|
||||
@ -784,12 +798,6 @@ public final class ExoPlayerTest {
|
||||
fakeMediaSource.setNewSourceInfo(adErrorTimeline);
|
||||
player.play();
|
||||
runUntilPlaybackState(player, Player.STATE_ENDED);
|
||||
Timeline.Window window =
|
||||
player.getCurrentTimeline().getWindow(/* windowIndex= */ 0, new Timeline.Window());
|
||||
Timeline.Period period =
|
||||
player
|
||||
.getCurrentTimeline()
|
||||
.getPeriod(/* periodIndex= */ 0, new Timeline.Period(), /* setIds= */ true);
|
||||
player.release();
|
||||
|
||||
// Content to content transition is ignored.
|
||||
@ -3418,8 +3426,7 @@ public final class ExoPlayerTest {
|
||||
.waitForPendingPlayerCommands()
|
||||
.play()
|
||||
.build();
|
||||
List<TrackGroupArray> trackGroupsList = new ArrayList<>();
|
||||
List<TrackSelectionArray> trackSelectionsList = new ArrayList<>();
|
||||
List<TracksInfo> tracksInfoList = new ArrayList<>();
|
||||
new ExoPlayerTestRunner.Builder(context)
|
||||
.setMediaSources(mediaSource)
|
||||
.setSupportedFormats(ExoPlayerTestRunner.VIDEO_FORMAT, ExoPlayerTestRunner.AUDIO_FORMAT)
|
||||
@ -3427,25 +3434,21 @@ public final class ExoPlayerTest {
|
||||
.setPlayerListener(
|
||||
new Player.Listener() {
|
||||
@Override
|
||||
public void onTracksChanged(
|
||||
TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
|
||||
trackGroupsList.add(trackGroups);
|
||||
trackSelectionsList.add(trackSelections);
|
||||
public void onTracksInfoChanged(TracksInfo tracksInfo) {
|
||||
tracksInfoList.add(tracksInfo);
|
||||
}
|
||||
})
|
||||
.build()
|
||||
.start()
|
||||
.blockUntilEnded(TIMEOUT_MS);
|
||||
assertThat(trackGroupsList).hasSize(3);
|
||||
assertThat(tracksInfoList).hasSize(3);
|
||||
// First track groups of the 1st period are reported.
|
||||
// Then the seek to an unprepared period will result in empty track groups and selections being
|
||||
// returned.
|
||||
// Then the seek to an unprepared period will result in empty track groups being returned.
|
||||
// Then the track groups of the 2nd period are reported.
|
||||
assertThat(trackGroupsList.get(0).get(0).getFormat(0))
|
||||
assertThat(tracksInfoList.get(0).getTrackGroupInfos().get(0).getTrackFormat(0))
|
||||
.isEqualTo(ExoPlayerTestRunner.VIDEO_FORMAT);
|
||||
assertThat(trackGroupsList.get(1)).isEqualTo(TrackGroupArray.EMPTY);
|
||||
assertThat(trackSelectionsList.get(1).get(0)).isNull();
|
||||
assertThat(trackGroupsList.get(2).get(0).getFormat(0))
|
||||
assertThat(tracksInfoList.get(1)).isEqualTo(TracksInfo.EMPTY);
|
||||
assertThat(tracksInfoList.get(2).getTrackGroupInfos().get(0).getTrackFormat(0))
|
||||
.isEqualTo(ExoPlayerTestRunner.AUDIO_FORMAT);
|
||||
}
|
||||
|
||||
@ -7991,7 +7994,6 @@ public final class ExoPlayerTest {
|
||||
};
|
||||
AtomicReference<Timeline> timelineAfterError = new AtomicReference<>();
|
||||
AtomicReference<TracksInfo> trackInfosAfterError = new AtomicReference<>();
|
||||
AtomicReference<TrackSelectionArray> trackSelectionsAfterError = new AtomicReference<>();
|
||||
AtomicInteger mediaItemIndexAfterError = new AtomicInteger();
|
||||
ActionSchedule actionSchedule =
|
||||
new ActionSchedule.Builder(TAG)
|
||||
@ -8005,7 +8007,6 @@ public final class ExoPlayerTest {
|
||||
public void onPlayerError(EventTime eventTime, PlaybackException error) {
|
||||
timelineAfterError.set(player.getCurrentTimeline());
|
||||
trackInfosAfterError.set(player.getCurrentTracksInfo());
|
||||
trackSelectionsAfterError.set(player.getCurrentTrackSelections());
|
||||
mediaItemIndexAfterError.set(player.getCurrentMediaItemIndex());
|
||||
}
|
||||
});
|
||||
@ -8037,8 +8038,8 @@ public final class ExoPlayerTest {
|
||||
assertThat(trackInfosAfterError.get().getTrackGroupInfos()).hasSize(1);
|
||||
assertThat(trackInfosAfterError.get().getTrackGroupInfos().get(0).getTrackFormat(0))
|
||||
.isEqualTo(ExoPlayerTestRunner.AUDIO_FORMAT);
|
||||
assertThat(trackSelectionsAfterError.get().get(0)).isNull(); // Video renderer.
|
||||
assertThat(trackSelectionsAfterError.get().get(1)).isNotNull(); // Audio renderer.
|
||||
assertThat(trackInfosAfterError.get().isTypeSelected(C.TRACK_TYPE_VIDEO)).isFalse();
|
||||
assertThat(trackInfosAfterError.get().isTypeSelected(C.TRACK_TYPE_AUDIO)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -10422,7 +10423,7 @@ public final class ExoPlayerTest {
|
||||
verify(listener, atLeastOnce()).onShuffleModeEnabledChanged(anyBoolean());
|
||||
verify(listener, atLeastOnce()).onPlaybackStateChanged(anyInt());
|
||||
verify(listener, atLeastOnce()).onIsLoadingChanged(anyBoolean());
|
||||
verify(listener, atLeastOnce()).onTracksChanged(any(), any());
|
||||
verify(listener, atLeastOnce()).onTracksInfoChanged(any());
|
||||
verify(listener, atLeastOnce()).onMediaMetadataChanged(any());
|
||||
verify(listener, atLeastOnce()).onPlayWhenReadyChanged(anyBoolean(), anyInt());
|
||||
verify(listener, atLeastOnce()).onIsPlayingChanged(anyBoolean());
|
||||
|
@ -49,8 +49,6 @@ import androidx.media3.common.PlaybackParameters;
|
||||
import androidx.media3.common.Player;
|
||||
import androidx.media3.common.Rating;
|
||||
import androidx.media3.common.Timeline;
|
||||
import androidx.media3.common.TrackGroupArray;
|
||||
import androidx.media3.common.TrackSelectionArray;
|
||||
import androidx.media3.common.TrackSelectionParameters;
|
||||
import androidx.media3.common.TracksInfo;
|
||||
import androidx.media3.common.VideoSize;
|
||||
@ -1681,20 +1679,6 @@ public class MediaController implements Player {
|
||||
return isConnected() ? impl.getMediaMetadata() : MediaMetadata.EMPTY;
|
||||
}
|
||||
|
||||
/** Returns {@link TrackGroupArray#EMPTY}. */
|
||||
@UnstableApi
|
||||
@Override
|
||||
public TrackGroupArray getCurrentTrackGroups() {
|
||||
return TrackGroupArray.EMPTY;
|
||||
}
|
||||
|
||||
/** Returns an empty {@link TrackSelectionArray}. */
|
||||
@UnstableApi
|
||||
@Override
|
||||
public TrackSelectionArray getCurrentTrackSelections() {
|
||||
return new TrackSelectionArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TracksInfo getCurrentTracksInfo() {
|
||||
return TracksInfo.EMPTY; // TODO(b/178486745)
|
||||
|
@ -31,8 +31,6 @@ import androidx.media3.common.PlaybackException;
|
||||
import androidx.media3.common.PlaybackParameters;
|
||||
import androidx.media3.common.Player;
|
||||
import androidx.media3.common.Timeline;
|
||||
import androidx.media3.common.TrackGroupArray;
|
||||
import androidx.media3.common.TrackSelectionArray;
|
||||
import androidx.media3.common.TrackSelectionParameters;
|
||||
import androidx.media3.common.TracksInfo;
|
||||
import androidx.media3.common.VideoSize;
|
||||
@ -1112,16 +1110,6 @@ public class MockPlayer implements Player {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrackGroupArray getCurrentTrackGroups() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrackSelectionArray getCurrentTrackSelections() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TracksInfo getCurrentTracksInfo() {
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -21,6 +21,8 @@ import androidx.media3.common.AudioAttributes;
|
||||
import androidx.media3.common.AuxEffectInfo;
|
||||
import androidx.media3.common.Format;
|
||||
import androidx.media3.common.PriorityTaskManager;
|
||||
import androidx.media3.common.TrackGroupArray;
|
||||
import androidx.media3.common.TrackSelectionArray;
|
||||
import androidx.media3.common.util.Clock;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.media3.exoplayer.DecoderCounters;
|
||||
@ -294,6 +296,16 @@ public class StubExoPlayer extends StubPlayer implements ExoPlayer {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrackGroupArray getCurrentTrackGroups() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrackSelectionArray getCurrentTrackSelections() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setForegroundMode(boolean foregroundMode) {
|
||||
throw new UnsupportedOperationException();
|
||||
|
@ -30,8 +30,6 @@ import androidx.media3.common.PlaybackException;
|
||||
import androidx.media3.common.PlaybackParameters;
|
||||
import androidx.media3.common.Player;
|
||||
import androidx.media3.common.Timeline;
|
||||
import androidx.media3.common.TrackGroupArray;
|
||||
import androidx.media3.common.TrackSelectionArray;
|
||||
import androidx.media3.common.TrackSelectionParameters;
|
||||
import androidx.media3.common.TracksInfo;
|
||||
import androidx.media3.common.VideoSize;
|
||||
@ -192,16 +190,6 @@ public class StubPlayer extends BasePlayer {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrackGroupArray getCurrentTrackGroups() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TrackSelectionArray getCurrentTrackSelections() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TracksInfo getCurrentTracksInfo() {
|
||||
throw new UnsupportedOperationException();
|
||||
|
Loading…
x
Reference in New Issue
Block a user