Move Player in common

This is the last CL to move Player in common.

#player-to-common

PiperOrigin-RevId: 353642347
This commit is contained in:
krocard 2021-01-25 15:29:07 +00:00 committed by Ian Baker
parent ec43735054
commit b0258e7192
8 changed files with 43 additions and 68 deletions

View File

@ -1080,23 +1080,6 @@ public final class C {
/** Indicates the track is intended for trick play. */
public static final int ROLE_FLAG_TRICK_PLAY = 1 << 14;
// TODO(b/172315872) Move usage back to Player.RepeatMode when Player is moved in common.
/**
* Repeat modes for playback. One of {@link #REPEAT_MODE_OFF}, {@link #REPEAT_MODE_ONE} or {@link
* #REPEAT_MODE_ALL}.
*/
@Documented
@Retention(RetentionPolicy.SOURCE)
@IntDef({REPEAT_MODE_OFF, REPEAT_MODE_ONE, REPEAT_MODE_ALL})
static @interface RepeatMode {}
/** Normal playback without repetition. */
/* package */ static final int REPEAT_MODE_OFF = 0;
/** "Repeat One" mode to repeat the currently playing window infinitely. */
/* package */ static final int REPEAT_MODE_ONE = 1;
/** "Repeat All" mode to repeat the entire timeline infinitely. */
/* package */ static final int REPEAT_MODE_ALL = 2;
/**
* Level of renderer support for a format. One of {@link #FORMAT_HANDLED}, {@link
* #FORMAT_EXCEEDS_CAPABILITIES}, {@link #FORMAT_UNSUPPORTED_DRM}, {@link

View File

@ -617,11 +617,14 @@ public interface Player {
default void onSeekProcessed() {}
/**
* Called when the player has started or stopped offload scheduling after a call to {@link
* Called when the player has started or stopped offload scheduling.
*
* <p>If using ExoPlayer, this is done by calling {@code
* ExoPlayer#experimentalSetOffloadSchedulingEnabled(boolean)}.
*
* <p>This method is experimental, and will be renamed or removed in a future release.
*/
// TODO(b/172315872) Move this method in a new ExoPlayer.EventListener.
default void onExperimentalOffloadSchedulingEnabledChanged(boolean offloadSchedulingEnabled) {}
/**
@ -739,9 +742,7 @@ public interface Player {
@Retention(RetentionPolicy.SOURCE)
@IntDef({STATE_IDLE, STATE_BUFFERING, STATE_READY, STATE_ENDED})
@interface State {}
/**
* The player does not have any media to play.
*/
/** The player does not have any media to play. */
int STATE_IDLE = 1;
/**
* The player is not able to immediately play from its current position. This state typically
@ -753,9 +754,7 @@ public interface Player {
* {@link #getPlayWhenReady()} is true, and paused otherwise.
*/
int STATE_READY = 3;
/**
* The player has finished playing the media.
*/
/** The player has finished playing the media. */
int STATE_ENDED = 4;
/**
@ -816,20 +815,20 @@ public interface Player {
* Normal playback without repetition. "Previous" and "Next" actions move to the previous and next
* windows respectively, and do nothing when there is no previous or next window to move to.
*/
int REPEAT_MODE_OFF = C.REPEAT_MODE_OFF;
int REPEAT_MODE_OFF = 0;
/**
* Repeats the currently playing window infinitely during ongoing playback. "Previous" and "Next"
* actions behave as they do in {@link #REPEAT_MODE_OFF}, moving to the previous and next windows
* respectively, and doing nothing when there is no previous or next window to move to.
*/
int REPEAT_MODE_ONE = C.REPEAT_MODE_ONE;
int REPEAT_MODE_ONE = 1;
/**
* Repeats the entire timeline infinitely. "Previous" and "Next" actions behave as they do in
* {@link #REPEAT_MODE_OFF}, but with looping at the ends so that "Previous" when playing the
* first window will move to the last window, and "Next" when playing the last window will move to
* the first window.
*/
int REPEAT_MODE_ALL = C.REPEAT_MODE_ALL;
int REPEAT_MODE_ALL = 2;
/**
* Reasons for position discontinuities. One of {@link #DISCONTINUITY_REASON_PERIOD_TRANSITION},
@ -1217,7 +1216,8 @@ public interface Player {
*
* @return The current repeat mode.
*/
@RepeatMode int getRepeatMode();
@RepeatMode
int getRepeatMode();
/**
* Sets whether shuffling of windows is enabled.
@ -1226,9 +1226,7 @@ public interface Player {
*/
void setShuffleModeEnabled(boolean shuffleModeEnabled);
/**
* Returns whether shuffling of windows is enabled.
*/
/** Returns whether shuffling of windows is enabled. */
boolean getShuffleModeEnabled();
/**
@ -1363,9 +1361,7 @@ public interface Player {
*/
void release();
/**
* Returns the number of renderers.
*/
/** Returns the number of renderers. */
int getRendererCount();
/**
@ -1404,14 +1400,10 @@ public interface Player {
@Nullable
Object getCurrentManifest();
/**
* Returns the current {@link Timeline}. Never null, but may be empty.
*/
/** Returns the current {@link Timeline}. Never null, but may be empty. */
Timeline getCurrentTimeline();
/**
* Returns the index of the period currently being played.
*/
/** Returns the index of the period currently being played. */
int getCurrentPeriodIndex();
/**
@ -1531,9 +1523,7 @@ public interface Player {
*/
boolean isCurrentWindowSeekable();
/**
* Returns whether the player is currently playing an ad.
*/
/** Returns whether the player is currently playing an ad. */
boolean isPlayingAd();
/**

View File

@ -734,14 +734,14 @@ public abstract class Timeline {
* @return The index of the next window, or {@link C#INDEX_UNSET} if this is the last window.
*/
public int getNextWindowIndex(
int windowIndex, @C.RepeatMode int repeatMode, boolean shuffleModeEnabled) {
int windowIndex, @Player.RepeatMode int repeatMode, boolean shuffleModeEnabled) {
switch (repeatMode) {
case C.REPEAT_MODE_OFF:
case Player.REPEAT_MODE_OFF:
return windowIndex == getLastWindowIndex(shuffleModeEnabled) ? C.INDEX_UNSET
: windowIndex + 1;
case C.REPEAT_MODE_ONE:
case Player.REPEAT_MODE_ONE:
return windowIndex;
case C.REPEAT_MODE_ALL:
case Player.REPEAT_MODE_ALL:
return windowIndex == getLastWindowIndex(shuffleModeEnabled)
? getFirstWindowIndex(shuffleModeEnabled) : windowIndex + 1;
default:
@ -759,14 +759,14 @@ public abstract class Timeline {
* @return The index of the previous window, or {@link C#INDEX_UNSET} if this is the first window.
*/
public int getPreviousWindowIndex(
int windowIndex, @C.RepeatMode int repeatMode, boolean shuffleModeEnabled) {
int windowIndex, @Player.RepeatMode int repeatMode, boolean shuffleModeEnabled) {
switch (repeatMode) {
case C.REPEAT_MODE_OFF:
case Player.REPEAT_MODE_OFF:
return windowIndex == getFirstWindowIndex(shuffleModeEnabled) ? C.INDEX_UNSET
: windowIndex - 1;
case C.REPEAT_MODE_ONE:
case Player.REPEAT_MODE_ONE:
return windowIndex;
case C.REPEAT_MODE_ALL:
case Player.REPEAT_MODE_ALL:
return windowIndex == getFirstWindowIndex(shuffleModeEnabled)
? getLastWindowIndex(shuffleModeEnabled) : windowIndex - 1;
default:
@ -847,7 +847,7 @@ public abstract class Timeline {
int periodIndex,
Period period,
Window window,
@C.RepeatMode int repeatMode,
@Player.RepeatMode int repeatMode,
boolean shuffleModeEnabled) {
int windowIndex = getPeriod(periodIndex, period).windowIndex;
if (getWindow(windowIndex, window).lastPeriodIndex == periodIndex) {
@ -875,7 +875,7 @@ public abstract class Timeline {
int periodIndex,
Period period,
Window window,
@C.RepeatMode int repeatMode,
@Player.RepeatMode int repeatMode,
boolean shuffleModeEnabled) {
return getNextPeriodIndex(periodIndex, period, window, repeatMode, shuffleModeEnabled)
== C.INDEX_UNSET;

View File

@ -15,8 +15,9 @@
*/
package com.google.android.exoplayer2.device;
// TODO(b/172315872) change back to @link after player migration to common.
/** A listener for changes of {@code Player.DeviceComponent}. */
import com.google.android.exoplayer2.Player;
/** A listener for changes of {@link Player.DeviceComponent}. */
public interface DeviceListener {
/** Called when the device information changes. */

View File

@ -73,5 +73,4 @@ public final class TrackSelectionArray {
TrackSelectionArray other = (TrackSelectionArray) obj;
return Arrays.equals(trackSelections, other.trackSelections);
}
}

View File

@ -40,12 +40,13 @@ public class TimelineTest {
Timeline timeline = new FakeTimeline(new TimelineWindowDefinition(1, 111));
TimelineAsserts.assertWindowTags(timeline, 111);
TimelineAsserts.assertPeriodCounts(timeline, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, C.REPEAT_MODE_OFF, false, C.INDEX_UNSET);
TimelineAsserts.assertPreviousWindowIndices(timeline, C.REPEAT_MODE_ONE, false, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, C.REPEAT_MODE_ALL, false, 0);
TimelineAsserts.assertNextWindowIndices(timeline, C.REPEAT_MODE_OFF, false, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, C.REPEAT_MODE_ONE, false, 0);
TimelineAsserts.assertNextWindowIndices(timeline, C.REPEAT_MODE_ALL, false, 0);
TimelineAsserts.assertPreviousWindowIndices(
timeline, Player.REPEAT_MODE_OFF, false, C.INDEX_UNSET);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, false, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, false, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, false, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, false, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, false, 0);
}
@Test
@ -53,12 +54,13 @@ public class TimelineTest {
Timeline timeline = new FakeTimeline(new TimelineWindowDefinition(5, 111));
TimelineAsserts.assertWindowTags(timeline, 111);
TimelineAsserts.assertPeriodCounts(timeline, 5);
TimelineAsserts.assertPreviousWindowIndices(timeline, C.REPEAT_MODE_OFF, false, C.INDEX_UNSET);
TimelineAsserts.assertPreviousWindowIndices(timeline, C.REPEAT_MODE_ONE, false, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, C.REPEAT_MODE_ALL, false, 0);
TimelineAsserts.assertNextWindowIndices(timeline, C.REPEAT_MODE_OFF, false, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, C.REPEAT_MODE_ONE, false, 0);
TimelineAsserts.assertNextWindowIndices(timeline, C.REPEAT_MODE_ALL, false, 0);
TimelineAsserts.assertPreviousWindowIndices(
timeline, Player.REPEAT_MODE_OFF, false, C.INDEX_UNSET);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, false, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, false, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, false, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, false, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, false, 0);
}
@Test