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
e4eb583922
commit
25e58f5f2a
@ -200,6 +200,13 @@
|
|||||||
`DefaultRenderersFactory#setAllowedVideoJoiningTimeMs` instead.
|
`DefaultRenderersFactory#setAllowedVideoJoiningTimeMs` instead.
|
||||||
* Remove all public `CronetDataSource` constructors. Use
|
* Remove all public `CronetDataSource` constructors. Use
|
||||||
`CronetDataSource.Factory` instead.
|
`CronetDataSource.Factory` instead.
|
||||||
|
* Remove `Player.Listener.onTracksChanged`. Use
|
||||||
|
`Player.Listener.onTracksInfoChanged` instead.
|
||||||
|
* Remove `Player.getCurrentTrackGroups` and
|
||||||
|
`Player.getCurrentTrackSelections`. Use `Player.getCurrentTracksInfo`
|
||||||
|
instead. You can also continue to use `ExoPlayer.getCurrentTrackGroups`
|
||||||
|
and `ExoPlayer.getCurrentTrackSelections`, although these methods remain
|
||||||
|
deprecated.
|
||||||
* Change the following `IntDefs` to `@Target(TYPE_USE)` only. This may break
|
* Change the following `IntDefs` to `@Target(TYPE_USE)` only. This may break
|
||||||
the compilation of usages in Kotlin, which can be fixed by moving the
|
the compilation of usages in Kotlin, which can be fixed by moving the
|
||||||
annotation to annotate the type (`Int`).
|
annotation to annotate the type (`Int`).
|
||||||
|
@ -38,18 +38,15 @@ import com.google.android.exoplayer2.PlaybackParameters;
|
|||||||
import com.google.android.exoplayer2.Player;
|
import com.google.android.exoplayer2.Player;
|
||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.TracksInfo;
|
import com.google.android.exoplayer2.TracksInfo;
|
||||||
|
import com.google.android.exoplayer2.TracksInfo.TrackGroupInfo;
|
||||||
import com.google.android.exoplayer2.audio.AudioAttributes;
|
import com.google.android.exoplayer2.audio.AudioAttributes;
|
||||||
import com.google.android.exoplayer2.source.TrackGroup;
|
import com.google.android.exoplayer2.source.TrackGroup;
|
||||||
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.trackselection.TrackSelection;
|
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
||||||
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;
|
||||||
import com.google.android.exoplayer2.util.Log;
|
import com.google.android.exoplayer2.util.Log;
|
||||||
import com.google.android.exoplayer2.util.MimeTypes;
|
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import com.google.android.exoplayer2.video.VideoSize;
|
import com.google.android.exoplayer2.video.VideoSize;
|
||||||
import com.google.android.gms.cast.CastStatusCodes;
|
import com.google.android.gms.cast.CastStatusCodes;
|
||||||
@ -67,7 +64,6 @@ import com.google.android.gms.common.api.PendingResult;
|
|||||||
import com.google.android.gms.common.api.ResultCallback;
|
import com.google.android.gms.common.api.ResultCallback;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|
||||||
import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,13 +109,10 @@ public final class CastPlayer extends BasePlayer {
|
|||||||
|
|
||||||
private static final String TAG = "CastPlayer";
|
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_VIDEO = 0;
|
||||||
private static final int RENDERER_INDEX_AUDIO = 1;
|
private static final int RENDERER_INDEX_AUDIO = 1;
|
||||||
private static final int RENDERER_INDEX_TEXT = 2;
|
private static final int RENDERER_INDEX_TEXT = 2;
|
||||||
private static final long PROGRESS_REPORT_PERIOD_MS = 1000;
|
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 static final long[] EMPTY_TRACK_ID_ARRAY = new long[0];
|
||||||
|
|
||||||
private final CastContext castContext;
|
private final CastContext castContext;
|
||||||
@ -144,8 +137,6 @@ public final class CastPlayer extends BasePlayer {
|
|||||||
private final StateHolder<PlaybackParameters> playbackParameters;
|
private final StateHolder<PlaybackParameters> playbackParameters;
|
||||||
@Nullable private RemoteMediaClient remoteMediaClient;
|
@Nullable private RemoteMediaClient remoteMediaClient;
|
||||||
private CastTimeline currentTimeline;
|
private CastTimeline currentTimeline;
|
||||||
private TrackGroupArray currentTrackGroups;
|
|
||||||
private TrackSelectionArray currentTrackSelection;
|
|
||||||
private TracksInfo currentTracksInfo;
|
private TracksInfo currentTracksInfo;
|
||||||
private Commands availableCommands;
|
private Commands availableCommands;
|
||||||
private @Player.State int playbackState;
|
private @Player.State int playbackState;
|
||||||
@ -222,8 +213,6 @@ public final class CastPlayer extends BasePlayer {
|
|||||||
playbackParameters = new StateHolder<>(PlaybackParameters.DEFAULT);
|
playbackParameters = new StateHolder<>(PlaybackParameters.DEFAULT);
|
||||||
playbackState = STATE_IDLE;
|
playbackState = STATE_IDLE;
|
||||||
currentTimeline = CastTimeline.EMPTY_CAST_TIMELINE;
|
currentTimeline = CastTimeline.EMPTY_CAST_TIMELINE;
|
||||||
currentTrackGroups = TrackGroupArray.EMPTY;
|
|
||||||
currentTrackSelection = EMPTY_TRACK_SELECTION_ARRAY;
|
|
||||||
currentTracksInfo = TracksInfo.EMPTY;
|
currentTracksInfo = TracksInfo.EMPTY;
|
||||||
availableCommands = new Commands.Builder().addAll(PERMANENT_AVAILABLE_COMMANDS).build();
|
availableCommands = new Commands.Builder().addAll(PERMANENT_AVAILABLE_COMMANDS).build();
|
||||||
pendingSeekWindowIndex = C.INDEX_UNSET;
|
pendingSeekWindowIndex = C.INDEX_UNSET;
|
||||||
@ -555,16 +544,6 @@ public final class CastPlayer extends BasePlayer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TrackGroupArray getCurrentTrackGroups() {
|
|
||||||
return currentTrackGroups;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TrackSelectionArray getCurrentTrackSelections() {
|
|
||||||
return currentTrackSelection;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TracksInfo getCurrentTracksInfo() {
|
public TracksInfo getCurrentTracksInfo() {
|
||||||
return currentTracksInfo;
|
return currentTracksInfo;
|
||||||
@ -839,9 +818,6 @@ public final class CastPlayer extends BasePlayer {
|
|||||||
getCurrentMediaItem(), MEDIA_ITEM_TRANSITION_REASON_AUTO));
|
getCurrentMediaItem(), MEDIA_ITEM_TRANSITION_REASON_AUTO));
|
||||||
}
|
}
|
||||||
if (updateTracksAndSelectionsAndNotifyIfChanged()) {
|
if (updateTracksAndSelectionsAndNotifyIfChanged()) {
|
||||||
listeners.queueEvent(
|
|
||||||
Player.EVENT_TRACKS_CHANGED,
|
|
||||||
listener -> listener.onTracksChanged(currentTrackGroups, currentTrackSelection));
|
|
||||||
listeners.queueEvent(
|
listeners.queueEvent(
|
||||||
Player.EVENT_TRACKS_CHANGED, listener -> listener.onTracksInfoChanged(currentTracksInfo));
|
Player.EVENT_TRACKS_CHANGED, listener -> listener.onTracksInfoChanged(currentTracksInfo));
|
||||||
}
|
}
|
||||||
@ -998,55 +974,33 @@ public final class CastPlayer extends BasePlayer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaStatus mediaStatus = getMediaStatus();
|
@Nullable MediaStatus mediaStatus = getMediaStatus();
|
||||||
MediaInfo mediaInfo = mediaStatus != null ? mediaStatus.getMediaInfo() : null;
|
@Nullable MediaInfo mediaInfo = mediaStatus != null ? mediaStatus.getMediaInfo() : null;
|
||||||
|
@Nullable
|
||||||
List<MediaTrack> castMediaTracks = mediaInfo != null ? mediaInfo.getMediaTracks() : null;
|
List<MediaTrack> castMediaTracks = mediaInfo != null ? mediaInfo.getMediaTracks() : null;
|
||||||
if (castMediaTracks == null || castMediaTracks.isEmpty()) {
|
if (castMediaTracks == null || castMediaTracks.isEmpty()) {
|
||||||
boolean hasChanged = !currentTrackGroups.isEmpty();
|
boolean hasChanged = !TracksInfo.EMPTY.equals(currentTracksInfo);
|
||||||
currentTrackGroups = TrackGroupArray.EMPTY;
|
|
||||||
currentTrackSelection = EMPTY_TRACK_SELECTION_ARRAY;
|
|
||||||
currentTracksInfo = TracksInfo.EMPTY;
|
currentTracksInfo = TracksInfo.EMPTY;
|
||||||
return hasChanged;
|
return hasChanged;
|
||||||
}
|
}
|
||||||
long[] activeTrackIds = mediaStatus.getActiveTrackIds();
|
@Nullable long[] activeTrackIds = mediaStatus.getActiveTrackIds();
|
||||||
if (activeTrackIds == null) {
|
if (activeTrackIds == null) {
|
||||||
activeTrackIds = EMPTY_TRACK_ID_ARRAY;
|
activeTrackIds = EMPTY_TRACK_ID_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackGroup[] trackGroups = new TrackGroup[castMediaTracks.size()];
|
TrackGroupInfo[] trackGroupInfos = new TrackGroupInfo[castMediaTracks.size()];
|
||||||
@NullableType TrackSelection[] trackSelections = new TrackSelection[RENDERER_COUNT];
|
|
||||||
TracksInfo.TrackGroupInfo[] trackGroupInfos =
|
|
||||||
new TracksInfo.TrackGroupInfo[castMediaTracks.size()];
|
|
||||||
for (int i = 0; i < castMediaTracks.size(); i++) {
|
for (int i = 0; i < castMediaTracks.size(); i++) {
|
||||||
MediaTrack mediaTrack = castMediaTracks.get(i);
|
MediaTrack mediaTrack = castMediaTracks.get(i);
|
||||||
trackGroups[i] =
|
TrackGroup trackGroup =
|
||||||
new TrackGroup(/* id= */ Integer.toString(i), CastUtils.mediaTrackToFormat(mediaTrack));
|
new TrackGroup(/* id= */ Integer.toString(i), CastUtils.mediaTrackToFormat(mediaTrack));
|
||||||
|
@C.FormatSupport int[] trackSupport = new int[] {C.FORMAT_HANDLED};
|
||||||
long id = mediaTrack.getId();
|
boolean[] trackSelected = new boolean[] {isTrackActive(mediaTrack.getId(), activeTrackIds)};
|
||||||
@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};
|
|
||||||
trackGroupInfos[i] =
|
trackGroupInfos[i] =
|
||||||
new TracksInfo.TrackGroupInfo(
|
new TrackGroupInfo(
|
||||||
trackGroups[i], /* adaptiveSupported= */ false, trackSupport, trackSelected);
|
trackGroup, /* adaptiveSupported= */ false, trackSupport, trackSelected);
|
||||||
}
|
}
|
||||||
TrackGroupArray newTrackGroups = new TrackGroupArray(trackGroups);
|
|
||||||
TrackSelectionArray newTrackSelections = new TrackSelectionArray(trackSelections);
|
|
||||||
TracksInfo newTracksInfo = new TracksInfo(ImmutableList.copyOf(trackGroupInfos));
|
TracksInfo newTracksInfo = new TracksInfo(ImmutableList.copyOf(trackGroupInfos));
|
||||||
|
if (!newTracksInfo.equals(currentTracksInfo)) {
|
||||||
if (!newTrackGroups.equals(currentTrackGroups)
|
|
||||||
|| !newTrackSelections.equals(currentTrackSelection)
|
|
||||||
|| !newTracksInfo.equals(currentTracksInfo)) {
|
|
||||||
currentTrackSelection = newTrackSelections;
|
|
||||||
currentTrackGroups = newTrackGroups;
|
|
||||||
currentTracksInfo = newTracksInfo;
|
currentTracksInfo = newTracksInfo;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1305,14 +1259,6 @@ public final class CastPlayer extends BasePlayer {
|
|||||||
return false;
|
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) {
|
private static int getCastRepeatMode(@RepeatMode int repeatMode) {
|
||||||
switch (repeatMode) {
|
switch (repeatMode) {
|
||||||
case REPEAT_MODE_ONE:
|
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 com.google.android.exoplayer2.ext.cast;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import com.google.android.exoplayer2.C;
|
|
||||||
import com.google.android.exoplayer2.Format;
|
|
||||||
import com.google.android.exoplayer2.source.TrackGroup;
|
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelection;
|
|
||||||
import com.google.android.exoplayer2.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 com.google.android.exoplayer2.ext.cast;
|
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
|
||||||
|
|
||||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
||||||
import com.google.android.exoplayer2.C;
|
|
||||||
import com.google.android.exoplayer2.Format;
|
|
||||||
import com.google.android.exoplayer2.source.TrackGroup;
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,9 +23,7 @@ import android.view.TextureView;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.audio.AudioAttributes;
|
import com.google.android.exoplayer2.audio.AudioAttributes;
|
||||||
import com.google.android.exoplayer2.metadata.Metadata;
|
import com.google.android.exoplayer2.metadata.Metadata;
|
||||||
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.trackselection.TrackSelectionArray;
|
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
||||||
import com.google.android.exoplayer2.video.VideoSize;
|
import com.google.android.exoplayer2.video.VideoSize;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -446,22 +444,6 @@ public class ForwardingPlayer implements Player {
|
|||||||
player.release();
|
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. */
|
/** Calls {@link Player#getCurrentTracksInfo()} on the delegate and returns the result. */
|
||||||
@Override
|
@Override
|
||||||
public TracksInfo getCurrentTracksInfo() {
|
public TracksInfo getCurrentTracksInfo() {
|
||||||
@ -850,12 +832,6 @@ public class ForwardingPlayer implements Player {
|
|||||||
listener.onMediaItemTransition(mediaItem, reason);
|
listener.onMediaItemTransition(mediaItem, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
|
|
||||||
listener.onTracksChanged(trackGroups, trackSelections);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTracksInfoChanged(TracksInfo tracksInfo) {
|
public void onTracksInfoChanged(TracksInfo tracksInfo) {
|
||||||
listener.onTracksInfoChanged(tracksInfo);
|
listener.onTracksInfoChanged(tracksInfo);
|
||||||
|
@ -33,10 +33,8 @@ import androidx.annotation.IntRange;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.audio.AudioAttributes;
|
import com.google.android.exoplayer2.audio.AudioAttributes;
|
||||||
import com.google.android.exoplayer2.metadata.Metadata;
|
import com.google.android.exoplayer2.metadata.Metadata;
|
||||||
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.trackselection.TrackSelection;
|
import com.google.android.exoplayer2.trackselection.TrackSelection;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
||||||
import com.google.android.exoplayer2.util.BundleableUtil;
|
import com.google.android.exoplayer2.util.BundleableUtil;
|
||||||
import com.google.android.exoplayer2.util.FlagSet;
|
import com.google.android.exoplayer2.util.FlagSet;
|
||||||
@ -670,23 +668,6 @@ public interface Player {
|
|||||||
default void onMediaItemTransition(
|
default void onMediaItemTransition(
|
||||||
@Nullable MediaItem mediaItem, @MediaItemTransitionReason int reason) {}
|
@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.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
default void onTracksChanged(
|
|
||||||
TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the available or selected tracks change.
|
* Called when the available or selected tracks change.
|
||||||
*
|
*
|
||||||
@ -2088,31 +2069,9 @@ public interface Player {
|
|||||||
void release();
|
void release();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the available track groups.
|
* Returns information about the current tracks.
|
||||||
*
|
*
|
||||||
* @see Listener#onTracksChanged(TrackGroupArray, TrackSelectionArray)
|
* @see Listener#onTracksInfoChanged(TracksInfo)
|
||||||
* @deprecated Use {@link #getCurrentTracksInfo()}.
|
|
||||||
*/
|
|
||||||
@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()}.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
TrackSelectionArray getCurrentTrackSelections();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the available tracks, as well as the tracks' support, type, and selection status.
|
|
||||||
*
|
|
||||||
* @see Listener#onTracksChanged(TrackGroupArray, TrackSelectionArray)
|
|
||||||
*/
|
*/
|
||||||
TracksInfo getCurrentTracksInfo();
|
TracksInfo getCurrentTracksInfo();
|
||||||
|
|
||||||
|
@ -44,9 +44,11 @@ import com.google.android.exoplayer2.metadata.MetadataRenderer;
|
|||||||
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
|
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.source.ShuffleOrder;
|
import com.google.android.exoplayer2.source.ShuffleOrder;
|
||||||
|
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.TextRenderer;
|
import com.google.android.exoplayer2.text.TextRenderer;
|
||||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||||
|
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
||||||
import com.google.android.exoplayer2.upstream.BandwidthMeter;
|
import com.google.android.exoplayer2.upstream.BandwidthMeter;
|
||||||
import com.google.android.exoplayer2.upstream.DataSource;
|
import com.google.android.exoplayer2.upstream.DataSource;
|
||||||
@ -1143,6 +1145,25 @@ public interface ExoPlayer extends Player {
|
|||||||
@Nullable
|
@Nullable
|
||||||
TrackSelector getTrackSelector();
|
TrackSelector getTrackSelector();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the available track groups.
|
||||||
|
*
|
||||||
|
* @see Listener#onTracksInfoChanged(TracksInfo)
|
||||||
|
* @deprecated Use {@link #getCurrentTracksInfo()}.
|
||||||
|
*/
|
||||||
|
@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()}.
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
TrackSelectionArray getCurrentTrackSelections();
|
||||||
|
|
||||||
/** Returns the {@link Looper} associated with the playback thread. */
|
/** Returns the {@link Looper} associated with the playback thread. */
|
||||||
Looper getPlaybackLooper();
|
Looper getPlaybackLooper();
|
||||||
|
|
||||||
|
@ -1880,11 +1880,6 @@ import java.util.concurrent.TimeoutException;
|
|||||||
}
|
}
|
||||||
if (previousPlaybackInfo.trackSelectorResult != newPlaybackInfo.trackSelectorResult) {
|
if (previousPlaybackInfo.trackSelectorResult != newPlaybackInfo.trackSelectorResult) {
|
||||||
trackSelector.onSelectionActivated(newPlaybackInfo.trackSelectorResult.info);
|
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(
|
listeners.queueEvent(
|
||||||
Player.EVENT_TRACKS_CHANGED,
|
Player.EVENT_TRACKS_CHANGED,
|
||||||
listener -> listener.onTracksInfoChanged(newPlaybackInfo.trackSelectorResult.tracksInfo));
|
listener -> listener.onTracksInfoChanged(newPlaybackInfo.trackSelectorResult.tracksInfo));
|
||||||
|
@ -47,9 +47,7 @@ import com.google.android.exoplayer2.metadata.Metadata;
|
|||||||
import com.google.android.exoplayer2.source.LoadEventInfo;
|
import com.google.android.exoplayer2.source.LoadEventInfo;
|
||||||
import com.google.android.exoplayer2.source.MediaLoadData;
|
import com.google.android.exoplayer2.source.MediaLoadData;
|
||||||
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
import com.google.android.exoplayer2.source.MediaSource.MediaPeriodId;
|
||||||
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.trackselection.TrackSelectionArray;
|
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
||||||
import com.google.android.exoplayer2.util.Clock;
|
import com.google.android.exoplayer2.util.Clock;
|
||||||
import com.google.android.exoplayer2.util.HandlerWrapper;
|
import com.google.android.exoplayer2.util.HandlerWrapper;
|
||||||
@ -482,13 +480,6 @@ public class DefaultAnalyticsCollector implements AnalyticsCollector {
|
|||||||
listener -> listener.onMediaItemTransition(eventTime, mediaItem, reason));
|
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
|
@Override
|
||||||
public void onTracksInfoChanged(TracksInfo tracksInfo) {
|
public void onTracksInfoChanged(TracksInfo tracksInfo) {
|
||||||
EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime();
|
EventTime eventTime = generateCurrentPlayerMediaPeriodEventTime();
|
||||||
|
@ -96,6 +96,7 @@ import com.google.android.exoplayer2.Player.DiscontinuityReason;
|
|||||||
import com.google.android.exoplayer2.Player.Listener;
|
import com.google.android.exoplayer2.Player.Listener;
|
||||||
import com.google.android.exoplayer2.Player.PositionInfo;
|
import com.google.android.exoplayer2.Player.PositionInfo;
|
||||||
import com.google.android.exoplayer2.Timeline.Window;
|
import com.google.android.exoplayer2.Timeline.Window;
|
||||||
|
import com.google.android.exoplayer2.TracksInfo.TrackGroupInfo;
|
||||||
import com.google.android.exoplayer2.analytics.AnalyticsListener;
|
import com.google.android.exoplayer2.analytics.AnalyticsListener;
|
||||||
import com.google.android.exoplayer2.audio.AudioAttributes;
|
import com.google.android.exoplayer2.audio.AudioAttributes;
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionEventListener;
|
import com.google.android.exoplayer2.drm.DrmSessionEventListener;
|
||||||
@ -143,7 +144,6 @@ import com.google.android.exoplayer2.testutil.FakeVideoRenderer;
|
|||||||
import com.google.android.exoplayer2.testutil.NoUidTimeline;
|
import com.google.android.exoplayer2.testutil.NoUidTimeline;
|
||||||
import com.google.android.exoplayer2.testutil.TestExoPlayerBuilder;
|
import com.google.android.exoplayer2.testutil.TestExoPlayerBuilder;
|
||||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
|
||||||
import com.google.android.exoplayer2.upstream.Allocation;
|
import com.google.android.exoplayer2.upstream.Allocation;
|
||||||
import com.google.android.exoplayer2.upstream.Allocator;
|
import com.google.android.exoplayer2.upstream.Allocator;
|
||||||
import com.google.android.exoplayer2.upstream.Loader;
|
import com.google.android.exoplayer2.upstream.Loader;
|
||||||
@ -267,8 +267,15 @@ public final class ExoPlayerTest {
|
|||||||
argThat(noUid(timeline)), eq(Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE));
|
argThat(noUid(timeline)), eq(Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE));
|
||||||
inOrder
|
inOrder
|
||||||
.verify(mockListener)
|
.verify(mockListener)
|
||||||
.onTracksChanged(
|
.onTracksInfoChanged(
|
||||||
eq(new TrackGroupArray(new TrackGroup(ExoPlayerTestRunner.VIDEO_FORMAT))), any());
|
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(anyInt());
|
||||||
inOrder.verify(mockListener, never()).onPositionDiscontinuity(any(), any(), anyInt());
|
inOrder.verify(mockListener, never()).onPositionDiscontinuity(any(), any(), anyInt());
|
||||||
assertThat(renderer.getFormatsRead()).containsExactly(ExoPlayerTestRunner.VIDEO_FORMAT);
|
assertThat(renderer.getFormatsRead()).containsExactly(ExoPlayerTestRunner.VIDEO_FORMAT);
|
||||||
@ -639,8 +646,15 @@ public final class ExoPlayerTest {
|
|||||||
argThat(noUid(thirdTimeline)), eq(Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE));
|
argThat(noUid(thirdTimeline)), eq(Player.TIMELINE_CHANGE_REASON_SOURCE_UPDATE));
|
||||||
inOrder
|
inOrder
|
||||||
.verify(mockPlayerListener)
|
.verify(mockPlayerListener)
|
||||||
.onTracksChanged(
|
.onTracksInfoChanged(
|
||||||
eq(new TrackGroupArray(new TrackGroup(ExoPlayerTestRunner.VIDEO_FORMAT))), any());
|
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();
|
assertThat(renderer.isEnded).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -774,12 +788,6 @@ public final class ExoPlayerTest {
|
|||||||
fakeMediaSource.setNewSourceInfo(adErrorTimeline);
|
fakeMediaSource.setNewSourceInfo(adErrorTimeline);
|
||||||
player.play();
|
player.play();
|
||||||
runUntilPlaybackState(player, Player.STATE_ENDED);
|
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();
|
player.release();
|
||||||
|
|
||||||
// Content to content transition is ignored.
|
// Content to content transition is ignored.
|
||||||
@ -3408,8 +3416,7 @@ public final class ExoPlayerTest {
|
|||||||
.waitForPendingPlayerCommands()
|
.waitForPendingPlayerCommands()
|
||||||
.play()
|
.play()
|
||||||
.build();
|
.build();
|
||||||
List<TrackGroupArray> trackGroupsList = new ArrayList<>();
|
List<TracksInfo> tracksInfoList = new ArrayList<>();
|
||||||
List<TrackSelectionArray> trackSelectionsList = new ArrayList<>();
|
|
||||||
new ExoPlayerTestRunner.Builder(context)
|
new ExoPlayerTestRunner.Builder(context)
|
||||||
.setMediaSources(mediaSource)
|
.setMediaSources(mediaSource)
|
||||||
.setSupportedFormats(ExoPlayerTestRunner.VIDEO_FORMAT, ExoPlayerTestRunner.AUDIO_FORMAT)
|
.setSupportedFormats(ExoPlayerTestRunner.VIDEO_FORMAT, ExoPlayerTestRunner.AUDIO_FORMAT)
|
||||||
@ -3417,25 +3424,21 @@ public final class ExoPlayerTest {
|
|||||||
.setPlayerListener(
|
.setPlayerListener(
|
||||||
new Player.Listener() {
|
new Player.Listener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTracksChanged(
|
public void onTracksInfoChanged(TracksInfo tracksInfo) {
|
||||||
TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
|
tracksInfoList.add(tracksInfo);
|
||||||
trackGroupsList.add(trackGroups);
|
|
||||||
trackSelectionsList.add(trackSelections);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.build()
|
.build()
|
||||||
.start()
|
.start()
|
||||||
.blockUntilEnded(TIMEOUT_MS);
|
.blockUntilEnded(TIMEOUT_MS);
|
||||||
assertThat(trackGroupsList).hasSize(3);
|
assertThat(tracksInfoList).hasSize(3);
|
||||||
// First track groups of the 1st period are reported.
|
// 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
|
// Then the seek to an unprepared period will result in empty track groups being returned.
|
||||||
// returned.
|
|
||||||
// Then the track groups of the 2nd period are reported.
|
// 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);
|
.isEqualTo(ExoPlayerTestRunner.VIDEO_FORMAT);
|
||||||
assertThat(trackGroupsList.get(1)).isEqualTo(TrackGroupArray.EMPTY);
|
assertThat(tracksInfoList.get(1)).isEqualTo(TracksInfo.EMPTY);
|
||||||
assertThat(trackSelectionsList.get(1).get(0)).isNull();
|
assertThat(tracksInfoList.get(2).getTrackGroupInfos().get(0).getTrackFormat(0))
|
||||||
assertThat(trackGroupsList.get(2).get(0).getFormat(0))
|
|
||||||
.isEqualTo(ExoPlayerTestRunner.AUDIO_FORMAT);
|
.isEqualTo(ExoPlayerTestRunner.AUDIO_FORMAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7981,7 +7984,6 @@ public final class ExoPlayerTest {
|
|||||||
};
|
};
|
||||||
AtomicReference<Timeline> timelineAfterError = new AtomicReference<>();
|
AtomicReference<Timeline> timelineAfterError = new AtomicReference<>();
|
||||||
AtomicReference<TracksInfo> trackInfosAfterError = new AtomicReference<>();
|
AtomicReference<TracksInfo> trackInfosAfterError = new AtomicReference<>();
|
||||||
AtomicReference<TrackSelectionArray> trackSelectionsAfterError = new AtomicReference<>();
|
|
||||||
AtomicInteger mediaItemIndexAfterError = new AtomicInteger();
|
AtomicInteger mediaItemIndexAfterError = new AtomicInteger();
|
||||||
ActionSchedule actionSchedule =
|
ActionSchedule actionSchedule =
|
||||||
new ActionSchedule.Builder(TAG)
|
new ActionSchedule.Builder(TAG)
|
||||||
@ -7995,7 +7997,6 @@ public final class ExoPlayerTest {
|
|||||||
public void onPlayerError(EventTime eventTime, PlaybackException error) {
|
public void onPlayerError(EventTime eventTime, PlaybackException error) {
|
||||||
timelineAfterError.set(player.getCurrentTimeline());
|
timelineAfterError.set(player.getCurrentTimeline());
|
||||||
trackInfosAfterError.set(player.getCurrentTracksInfo());
|
trackInfosAfterError.set(player.getCurrentTracksInfo());
|
||||||
trackSelectionsAfterError.set(player.getCurrentTrackSelections());
|
|
||||||
mediaItemIndexAfterError.set(player.getCurrentMediaItemIndex());
|
mediaItemIndexAfterError.set(player.getCurrentMediaItemIndex());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -8027,8 +8028,8 @@ public final class ExoPlayerTest {
|
|||||||
assertThat(trackInfosAfterError.get().getTrackGroupInfos()).hasSize(1);
|
assertThat(trackInfosAfterError.get().getTrackGroupInfos()).hasSize(1);
|
||||||
assertThat(trackInfosAfterError.get().getTrackGroupInfos().get(0).getTrackFormat(0))
|
assertThat(trackInfosAfterError.get().getTrackGroupInfos().get(0).getTrackFormat(0))
|
||||||
.isEqualTo(ExoPlayerTestRunner.AUDIO_FORMAT);
|
.isEqualTo(ExoPlayerTestRunner.AUDIO_FORMAT);
|
||||||
assertThat(trackSelectionsAfterError.get().get(0)).isNull(); // Video renderer.
|
assertThat(trackInfosAfterError.get().isTypeSelected(C.TRACK_TYPE_VIDEO)).isFalse();
|
||||||
assertThat(trackSelectionsAfterError.get().get(1)).isNotNull(); // Audio renderer.
|
assertThat(trackInfosAfterError.get().isTypeSelected(C.TRACK_TYPE_AUDIO)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -10412,7 +10413,7 @@ public final class ExoPlayerTest {
|
|||||||
verify(listener, atLeastOnce()).onShuffleModeEnabledChanged(anyBoolean());
|
verify(listener, atLeastOnce()).onShuffleModeEnabledChanged(anyBoolean());
|
||||||
verify(listener, atLeastOnce()).onPlaybackStateChanged(anyInt());
|
verify(listener, atLeastOnce()).onPlaybackStateChanged(anyInt());
|
||||||
verify(listener, atLeastOnce()).onIsLoadingChanged(anyBoolean());
|
verify(listener, atLeastOnce()).onIsLoadingChanged(anyBoolean());
|
||||||
verify(listener, atLeastOnce()).onTracksChanged(any(), any());
|
verify(listener, atLeastOnce()).onTracksInfoChanged(any());
|
||||||
verify(listener, atLeastOnce()).onMediaMetadataChanged(any());
|
verify(listener, atLeastOnce()).onMediaMetadataChanged(any());
|
||||||
verify(listener, atLeastOnce()).onPlayWhenReadyChanged(anyBoolean(), anyInt());
|
verify(listener, atLeastOnce()).onPlayWhenReadyChanged(anyBoolean(), anyInt());
|
||||||
verify(listener, atLeastOnce()).onIsPlayingChanged(anyBoolean());
|
verify(listener, atLeastOnce()).onIsPlayingChanged(anyBoolean());
|
||||||
|
@ -30,6 +30,8 @@ import com.google.android.exoplayer2.audio.AuxEffectInfo;
|
|||||||
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
import com.google.android.exoplayer2.decoder.DecoderCounters;
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
import com.google.android.exoplayer2.source.ShuffleOrder;
|
import com.google.android.exoplayer2.source.ShuffleOrder;
|
||||||
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
|
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
import com.google.android.exoplayer2.trackselection.TrackSelector;
|
||||||
import com.google.android.exoplayer2.util.Clock;
|
import com.google.android.exoplayer2.util.Clock;
|
||||||
import com.google.android.exoplayer2.util.PriorityTaskManager;
|
import com.google.android.exoplayer2.util.PriorityTaskManager;
|
||||||
@ -292,6 +294,16 @@ public class StubExoPlayer extends StubPlayer implements ExoPlayer {
|
|||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TrackGroupArray getCurrentTrackGroups() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TrackSelectionArray getCurrentTrackSelections() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setForegroundMode(boolean foregroundMode) {
|
public void setForegroundMode(boolean foregroundMode) {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
@ -31,9 +31,7 @@ import com.google.android.exoplayer2.Player;
|
|||||||
import com.google.android.exoplayer2.Timeline;
|
import com.google.android.exoplayer2.Timeline;
|
||||||
import com.google.android.exoplayer2.TracksInfo;
|
import com.google.android.exoplayer2.TracksInfo;
|
||||||
import com.google.android.exoplayer2.audio.AudioAttributes;
|
import com.google.android.exoplayer2.audio.AudioAttributes;
|
||||||
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.trackselection.TrackSelectionArray;
|
|
||||||
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
import com.google.android.exoplayer2.trackselection.TrackSelectionParameters;
|
||||||
import com.google.android.exoplayer2.video.VideoSize;
|
import com.google.android.exoplayer2.video.VideoSize;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -190,16 +188,6 @@ public class StubPlayer extends BasePlayer {
|
|||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public TrackGroupArray getCurrentTrackGroups() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public TrackSelectionArray getCurrentTrackSelections() {
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TracksInfo getCurrentTracksInfo() {
|
public TracksInfo getCurrentTracksInfo() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user