Commit 554a3994 by andrewlewis Committed by Oliver Woodman

Switch to non-deprecated player constants

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=162605429
parent 8d56f904
Showing with 224 additions and 228 deletions
......@@ -20,9 +20,9 @@ import android.util.Log;
import android.view.Surface;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.RendererCapabilities;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.audio.AudioRendererEventListener;
......@@ -55,8 +55,8 @@ import java.util.Locale;
/**
* Logs player events using {@link Log}.
*/
/* package */ final class EventLogger implements ExoPlayer.EventListener,
AudioRendererEventListener, VideoRendererEventListener, AdaptiveMediaSourceEventListener,
/* package */ final class EventLogger implements Player.EventListener, AudioRendererEventListener,
VideoRendererEventListener, AdaptiveMediaSourceEventListener,
ExtractorMediaSource.EventListener, DefaultDrmSessionManager.EventListener,
MetadataRenderer.Output {
......@@ -82,7 +82,7 @@ import java.util.Locale;
startTimeMs = SystemClock.elapsedRealtime();
}
// ExoPlayer.EventListener
// Player.EventListener
@Override
public void onLoadingChanged(boolean isLoading) {
......@@ -96,7 +96,7 @@ import java.util.Locale;
}
@Override
public void onRepeatModeChanged(@ExoPlayer.RepeatMode int repeatMode) {
public void onRepeatModeChanged(@Player.RepeatMode int repeatMode) {
Log.d(TAG, "repeatMode [" + getRepeatModeString(repeatMode) + "]");
}
......@@ -412,13 +412,13 @@ import java.util.Locale;
private static String getStateString(int state) {
switch (state) {
case ExoPlayer.STATE_BUFFERING:
case Player.STATE_BUFFERING:
return "B";
case ExoPlayer.STATE_ENDED:
case Player.STATE_ENDED:
return "E";
case ExoPlayer.STATE_IDLE:
case Player.STATE_IDLE:
return "I";
case ExoPlayer.STATE_READY:
case Player.STATE_READY:
return "R";
default:
return "?";
......@@ -466,13 +466,13 @@ import java.util.Locale;
return enabled ? "[X]" : "[ ]";
}
private static String getRepeatModeString(@ExoPlayer.RepeatMode int repeatMode) {
private static String getRepeatModeString(@Player.RepeatMode int repeatMode) {
switch (repeatMode) {
case ExoPlayer.REPEAT_MODE_OFF:
case Player.REPEAT_MODE_OFF:
return "OFF";
case ExoPlayer.REPEAT_MODE_ONE:
case Player.REPEAT_MODE_ONE:
return "ONE";
case ExoPlayer.REPEAT_MODE_ALL:
case Player.REPEAT_MODE_ALL:
return "ALL";
default:
return "?";
......
......@@ -36,9 +36,9 @@ import android.widget.Toast;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Player.EventListener;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline;
......@@ -480,7 +480,7 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi
}
}
// ExoPlayer.EventListener implementation
// Player.EventListener implementation
@Override
public void onLoadingChanged(boolean isLoading) {
......@@ -489,7 +489,7 @@ public class PlayerActivity extends Activity implements OnClickListener, EventLi
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ExoPlayer.STATE_ENDED) {
if (playbackState == Player.STATE_ENDED) {
showControls();
}
updateButtonVisibilities();
......
......@@ -23,6 +23,7 @@ import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
......@@ -57,7 +58,7 @@ public class FlacPlaybackTest extends InstrumentationTestCase {
}
}
private static class TestPlaybackThread extends Thread implements ExoPlayer.EventListener {
private static class TestPlaybackThread extends Thread implements Player.EventListener {
private final Context context;
private final Uri uri;
......@@ -120,8 +121,8 @@ public class FlacPlaybackTest extends InstrumentationTestCase {
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ExoPlayer.STATE_ENDED
|| (playbackState == ExoPlayer.STATE_IDLE && playbackException != null)) {
if (playbackState == Player.STATE_ENDED
|| (playbackState == Player.STATE_IDLE && playbackException != null)) {
releasePlayerAndQuitLooper();
}
}
......
......@@ -43,6 +43,7 @@ import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerLibraryInfo;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
......@@ -54,7 +55,7 @@ import java.util.List;
/**
* Loads ads using the IMA SDK. All methods are called on the main thread.
*/
public final class ImaAdsLoader implements ExoPlayer.EventListener, VideoAdPlayer,
public final class ImaAdsLoader implements Player.EventListener, VideoAdPlayer,
ContentProgressProvider, AdErrorListener, AdsLoadedListener, AdEventListener {
/**
......@@ -107,7 +108,7 @@ public final class ImaAdsLoader implements ExoPlayer.EventListener, VideoAdPlaye
private final AdsLoader adsLoader;
private EventListener eventListener;
private ExoPlayer player;
private Player player;
private VideoProgressUpdate lastContentProgress;
private VideoProgressUpdate lastAdProgress;
......@@ -485,7 +486,7 @@ public final class ImaAdsLoader implements ExoPlayer.EventListener, VideoAdPlaye
throw new IllegalStateException();
}
// ExoPlayer.EventListener implementation.
// Player.EventListener implementation.
@Override
public void onTimelineChanged(Timeline timeline, Object manifest) {
......@@ -516,9 +517,9 @@ public final class ImaAdsLoader implements ExoPlayer.EventListener, VideoAdPlaye
return;
}
if (!imaPlayingAd && playbackState == ExoPlayer.STATE_BUFFERING && playWhenReady) {
if (!imaPlayingAd && playbackState == Player.STATE_BUFFERING && playWhenReady) {
checkForContentComplete();
} else if (imaPlayingAd && playbackState == ExoPlayer.STATE_ENDED) {
} else if (imaPlayingAd && playbackState == Player.STATE_ENDED) {
// IMA is waiting for the ad playback to finish so invoke the callback now.
// Either CONTENT_RESUME_REQUESTED will be passed next, or playAd will be called again.
for (VideoAdPlayerCallback callback : adCallbacks) {
......
......@@ -23,6 +23,7 @@ import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
......@@ -57,7 +58,7 @@ public class OpusPlaybackTest extends InstrumentationTestCase {
}
}
private static class TestPlaybackThread extends Thread implements ExoPlayer.EventListener {
private static class TestPlaybackThread extends Thread implements Player.EventListener {
private final Context context;
private final Uri uri;
......@@ -120,8 +121,8 @@ public class OpusPlaybackTest extends InstrumentationTestCase {
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ExoPlayer.STATE_ENDED
|| (playbackState == ExoPlayer.STATE_IDLE && playbackException != null)) {
if (playbackState == Player.STATE_ENDED
|| (playbackState == Player.STATE_IDLE && playbackException != null)) {
releasePlayerAndQuitLooper();
}
}
......
......@@ -24,6 +24,7 @@ import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.extractor.mkv.MatroskaExtractor;
......@@ -86,7 +87,7 @@ public class VpxPlaybackTest extends InstrumentationTestCase {
}
}
private static class TestPlaybackThread extends Thread implements ExoPlayer.EventListener {
private static class TestPlaybackThread extends Thread implements Player.EventListener {
private final Context context;
private final Uri uri;
......@@ -152,8 +153,8 @@ public class VpxPlaybackTest extends InstrumentationTestCase {
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ExoPlayer.STATE_ENDED
|| (playbackState == ExoPlayer.STATE_IDLE && playbackException != null)) {
if (playbackState == Player.STATE_ENDED
|| (playbackState == Player.STATE_IDLE && playbackException != null)) {
releasePlayerAndQuitLooper();
}
}
......
......@@ -216,13 +216,13 @@ public final class ExoPlayerTest extends TestCase {
new TimelineWindowDefinition(true, false, 100000),
new TimelineWindowDefinition(true, false, 100000));
final int[] actionSchedule = { // 0 -> 1
ExoPlayer.REPEAT_MODE_ONE, // 1 -> 1
ExoPlayer.REPEAT_MODE_OFF, // 1 -> 2
ExoPlayer.REPEAT_MODE_ONE, // 2 -> 2
ExoPlayer.REPEAT_MODE_ALL, // 2 -> 0
ExoPlayer.REPEAT_MODE_ONE, // 0 -> 0
Player.REPEAT_MODE_ONE, // 1 -> 1
Player.REPEAT_MODE_OFF, // 1 -> 2
Player.REPEAT_MODE_ONE, // 2 -> 2
Player.REPEAT_MODE_ALL, // 2 -> 0
Player.REPEAT_MODE_ONE, // 0 -> 0
-1, // 0 -> 0
ExoPlayer.REPEAT_MODE_OFF, // 0 -> 1
Player.REPEAT_MODE_OFF, // 0 -> 1
-1, // 1 -> 2
-1 // 2 -> ended
};
......
......@@ -33,23 +33,23 @@ public class TimelineTest extends TestCase {
Timeline timeline = new FakeTimeline(new TimelineWindowDefinition(1, 111));
TimelineAsserts.assertWindowIds(timeline, 111);
TimelineAsserts.assertPeriodCounts(timeline, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 0);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, 0);
}
public void testMultiPeriodTimeline() {
Timeline timeline = new FakeTimeline(new TimelineWindowDefinition(5, 111));
TimelineAsserts.assertWindowIds(timeline, 111);
TimelineAsserts.assertPeriodCounts(timeline, 5);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 0);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, 0);
}
}
......@@ -17,7 +17,7 @@ package com.google.android.exoplayer2.source;
import android.test.InstrumentationTestCase;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Timeline.Period;
import com.google.android.exoplayer2.Timeline.Window;
......@@ -109,14 +109,13 @@ public final class ClippingMediaSourceTest extends InstrumentationTestCase {
TEST_PERIOD_DURATION_US - TEST_CLIP_AMOUNT_US);
TimelineAsserts.assertWindowIds(clippedTimeline, 111);
TimelineAsserts.assertPeriodCounts(clippedTimeline, 1);
TimelineAsserts.assertPreviousWindowIndices(clippedTimeline, ExoPlayer.REPEAT_MODE_OFF,
C.INDEX_UNSET);
TimelineAsserts.assertPreviousWindowIndices(clippedTimeline, ExoPlayer.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertPreviousWindowIndices(clippedTimeline, ExoPlayer.REPEAT_MODE_ALL, 0);
TimelineAsserts.assertNextWindowIndices(clippedTimeline, ExoPlayer.REPEAT_MODE_OFF,
C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(clippedTimeline, ExoPlayer.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertNextWindowIndices(clippedTimeline, ExoPlayer.REPEAT_MODE_ALL, 0);
TimelineAsserts.assertPreviousWindowIndices(
clippedTimeline, Player.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertPreviousWindowIndices(clippedTimeline, Player.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertPreviousWindowIndices(clippedTimeline, Player.REPEAT_MODE_ALL, 0);
TimelineAsserts.assertNextWindowIndices(clippedTimeline, Player.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(clippedTimeline, Player.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertNextWindowIndices(clippedTimeline, Player.REPEAT_MODE_ALL, 0);
}
/**
......
......@@ -16,7 +16,7 @@
package com.google.android.exoplayer2.source;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.testutil.FakeMediaSource;
import com.google.android.exoplayer2.testutil.FakeTimeline;
......@@ -34,22 +34,22 @@ public final class ConcatenatingMediaSourceTest extends TestCase {
Timeline timeline = getConcatenatedTimeline(false, createFakeTimeline(3, 111));
TimelineAsserts.assertWindowIds(timeline, 111);
TimelineAsserts.assertPeriodCounts(timeline, 3);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 0);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, 0);
timeline = getConcatenatedTimeline(true, createFakeTimeline(3, 111));
TimelineAsserts.assertWindowIds(timeline, 111);
TimelineAsserts.assertPeriodCounts(timeline, 3);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 0);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, 0);
}
public void testMultipleMediaSources() {
......@@ -58,26 +58,24 @@ public final class ConcatenatingMediaSourceTest extends TestCase {
Timeline timeline = getConcatenatedTimeline(false, timelines);
TimelineAsserts.assertWindowIds(timeline, 111, 222, 333);
TimelineAsserts.assertPeriodCounts(timeline, 3, 1, 3);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF, C.INDEX_UNSET,
0, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 2, 0, 1);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF,
1, 2, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 1, 2, 0);
TimelineAsserts.assertPreviousWindowIndices(
timeline, Player.REPEAT_MODE_OFF, C.INDEX_UNSET, 0, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, 2, 0, 1);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, 1, 2, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, 1, 2, 0);
timeline = getConcatenatedTimeline(true, timelines);
TimelineAsserts.assertWindowIds(timeline, 111, 222, 333);
TimelineAsserts.assertPeriodCounts(timeline, 3, 1, 3);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF,
C.INDEX_UNSET, 0, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 2, 0, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 2, 0, 1);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF,
1, 2, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 1, 2, 0);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 1, 2, 0);
TimelineAsserts.assertPreviousWindowIndices(
timeline, Player.REPEAT_MODE_OFF, C.INDEX_UNSET, 0, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, 2, 0, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, 2, 0, 1);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, 1, 2, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, 1, 2, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, 1, 2, 0);
}
public void testNestedMediaSources() {
......@@ -86,14 +84,14 @@ public final class ConcatenatingMediaSourceTest extends TestCase {
getConcatenatedTimeline(true, createFakeTimeline(1, 333), createFakeTimeline(1, 444)));
TimelineAsserts.assertWindowIds(timeline, 111, 222, 333, 444);
TimelineAsserts.assertPeriodCounts(timeline, 1, 1, 1, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF,
C.INDEX_UNSET, 0, 1, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0, 1, 3, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 3, 0, 1, 2);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF,
1, 2, 3, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0, 1, 3, 2);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 1, 2, 3, 0);
TimelineAsserts.assertPreviousWindowIndices(
timeline, Player.REPEAT_MODE_OFF, C.INDEX_UNSET, 0, 1, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0, 1, 3, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, 3, 0, 1, 2);
TimelineAsserts.assertNextWindowIndices(
timeline, Player.REPEAT_MODE_OFF, 1, 2, 3, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0, 1, 3, 2);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, 1, 2, 3, 0);
}
/**
......
......@@ -120,14 +120,13 @@ public final class DynamicConcatenatingMediaSourceTest extends TestCase {
}
// Assert correct next and previous indices behavior after some insertions and removals.
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF,
1, 2, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 1, 2, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF,
C.INDEX_UNSET, 0, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 2, 0, 1);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, 1, 2, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, 1, 2, 0);
TimelineAsserts.assertPreviousWindowIndices(
timeline, Player.REPEAT_MODE_OFF, C.INDEX_UNSET, 0, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, 2, 0, 1);
// Remove at front of queue.
mediaSource.removeMediaSource(0);
......
......@@ -16,7 +16,7 @@
package com.google.android.exoplayer2.source;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.testutil.FakeMediaSource;
import com.google.android.exoplayer2.testutil.FakeTimeline;
......@@ -42,31 +42,30 @@ public class LoopingMediaSourceTest extends TestCase {
Timeline timeline = getLoopingTimeline(multiWindowTimeline, 1);
TimelineAsserts.assertWindowIds(timeline, 111, 222, 333);
TimelineAsserts.assertPeriodCounts(timeline, 1, 1, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF,
C.INDEX_UNSET, 0, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 2, 0, 1);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF,
1, 2, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 1, 2, 0);
TimelineAsserts.assertPreviousWindowIndices(
timeline, Player.REPEAT_MODE_OFF, C.INDEX_UNSET, 0, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, 2, 0, 1);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, 1, 2, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, 1, 2, 0);
}
public void testMultiLoop() {
Timeline timeline = getLoopingTimeline(multiWindowTimeline, 3);
TimelineAsserts.assertWindowIds(timeline, 111, 222, 333, 111, 222, 333, 111, 222, 333);
TimelineAsserts.assertPeriodCounts(timeline, 1, 1, 1, 1, 1, 1, 1, 1, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF,
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_OFF,
C.INDEX_UNSET, 0, 1, 2, 3, 4, 5, 6, 7, 8);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE,
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE,
0, 1, 2, 3, 4, 5, 6, 7, 8);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL,
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL,
8, 0, 1, 2, 3, 4, 5, 6, 7);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF,
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF,
1, 2, 3, 4, 5, 6, 7, 8, C.INDEX_UNSET);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE,
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE,
0, 1, 2, 3, 4, 5, 6, 7, 8);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL,
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL,
1, 2, 3, 4, 5, 6, 7, 8, 0);
}
......@@ -74,12 +73,12 @@ public class LoopingMediaSourceTest extends TestCase {
Timeline timeline = getLoopingTimeline(multiWindowTimeline, Integer.MAX_VALUE);
TimelineAsserts.assertWindowIds(timeline, 111, 222, 333);
TimelineAsserts.assertPeriodCounts(timeline, 1, 1, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF, 2, 0, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 2, 0, 1);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_OFF, 1, 2, 0);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertNextWindowIndices(timeline, ExoPlayer.REPEAT_MODE_ALL, 1, 2, 0);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_OFF, 2, 0, 1);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertPreviousWindowIndices(timeline, Player.REPEAT_MODE_ALL, 2, 0, 1);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_OFF, 1, 2, 0);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ONE, 0, 1, 2);
TimelineAsserts.assertNextWindowIndices(timeline, Player.REPEAT_MODE_ALL, 1, 2, 0);
}
/**
......
......@@ -86,8 +86,8 @@ import java.util.concurrent.CopyOnWriteArraySet;
this.renderers = Assertions.checkNotNull(renderers);
this.trackSelector = Assertions.checkNotNull(trackSelector);
this.playWhenReady = false;
this.repeatMode = REPEAT_MODE_OFF;
this.playbackState = STATE_IDLE;
this.repeatMode = Player.REPEAT_MODE_OFF;
this.playbackState = Player.STATE_IDLE;
this.listeners = new CopyOnWriteArraySet<>();
emptyTrackSelections = new TrackSelectionArray(new TrackSelection[renderers.length]);
timeline = Timeline.EMPTY;
......
......@@ -172,7 +172,7 @@ import java.io.IOException;
private boolean rebuffering;
private boolean isLoading;
private int state;
private @ExoPlayer.RepeatMode int repeatMode;
private @Player.RepeatMode int repeatMode;
private int customMessagesSent;
private int customMessagesProcessed;
private long elapsedRealtimeUs;
......@@ -188,7 +188,7 @@ import java.io.IOException;
private Timeline timeline;
public ExoPlayerImplInternal(Renderer[] renderers, TrackSelector trackSelector,
LoadControl loadControl, boolean playWhenReady, @ExoPlayer.RepeatMode int repeatMode,
LoadControl loadControl, boolean playWhenReady, @Player.RepeatMode int repeatMode,
Handler eventHandler, PlaybackInfo playbackInfo, ExoPlayer player) {
this.renderers = renderers;
this.trackSelector = trackSelector;
......@@ -196,7 +196,7 @@ import java.io.IOException;
this.playWhenReady = playWhenReady;
this.repeatMode = repeatMode;
this.eventHandler = eventHandler;
this.state = ExoPlayer.STATE_IDLE;
this.state = Player.STATE_IDLE;
this.playbackInfo = playbackInfo;
this.player = player;
......@@ -230,7 +230,7 @@ import java.io.IOException;
handler.obtainMessage(MSG_SET_PLAY_WHEN_READY, playWhenReady ? 1 : 0, 0).sendToTarget();
}
public void setRepeatMode(@ExoPlayer.RepeatMode int repeatMode) {
public void setRepeatMode(@Player.RepeatMode int repeatMode) {
handler.obtainMessage(MSG_SET_REPEAT_MODE, repeatMode, 0).sendToTarget();
}
......@@ -423,7 +423,7 @@ import java.io.IOException;
}
this.mediaSource = mediaSource;
mediaSource.prepareSource(player, true, this);
setState(ExoPlayer.STATE_BUFFERING);
setState(Player.STATE_BUFFERING);
handler.sendEmptyMessage(MSG_DO_SOME_WORK);
}
......@@ -434,16 +434,16 @@ import java.io.IOException;
stopRenderers();
updatePlaybackPositions();
} else {
if (state == ExoPlayer.STATE_READY) {
if (state == Player.STATE_READY) {
startRenderers();
handler.sendEmptyMessage(MSG_DO_SOME_WORK);
} else if (state == ExoPlayer.STATE_BUFFERING) {
} else if (state == Player.STATE_BUFFERING) {
handler.sendEmptyMessage(MSG_DO_SOME_WORK);
}
}
}
private void setRepeatModeInternal(@ExoPlayer.RepeatMode int repeatMode)
private void setRepeatModeInternal(@Player.RepeatMode int repeatMode)
throws ExoPlaybackException {
this.repeatMode = repeatMode;
mediaPeriodInfoSequence.setRepeatMode(repeatMode);
......@@ -594,38 +594,38 @@ import java.io.IOException;
&& (playingPeriodDurationUs == C.TIME_UNSET
|| playingPeriodDurationUs <= playbackInfo.positionUs)
&& playingPeriodHolder.info.isFinal) {
setState(ExoPlayer.STATE_ENDED);
setState(Player.STATE_ENDED);
stopRenderers();
} else if (state == ExoPlayer.STATE_BUFFERING) {
} else if (state == Player.STATE_BUFFERING) {
boolean isNewlyReady = enabledRenderers.length > 0
? (allRenderersReadyOrEnded
&& loadingPeriodHolder.haveSufficientBuffer(rebuffering, rendererPositionUs))
: isTimelineReady(playingPeriodDurationUs);
if (isNewlyReady) {
setState(ExoPlayer.STATE_READY);
setState(Player.STATE_READY);
if (playWhenReady) {
startRenderers();
}
}
} else if (state == ExoPlayer.STATE_READY) {
} else if (state == Player.STATE_READY) {
boolean isStillReady = enabledRenderers.length > 0 ? allRenderersReadyOrEnded
: isTimelineReady(playingPeriodDurationUs);
if (!isStillReady) {
rebuffering = playWhenReady;
setState(ExoPlayer.STATE_BUFFERING);
setState(Player.STATE_BUFFERING);
stopRenderers();
}
}
if (state == ExoPlayer.STATE_BUFFERING) {
if (state == Player.STATE_BUFFERING) {
for (Renderer renderer : enabledRenderers) {
renderer.maybeThrowStreamError();
}
}
if ((playWhenReady && state == ExoPlayer.STATE_READY) || state == ExoPlayer.STATE_BUFFERING) {
if ((playWhenReady && state == Player.STATE_READY) || state == Player.STATE_BUFFERING) {
scheduleNextWork(operationStartTimeMs, RENDERING_INTERVAL_MS);
} else if (enabledRenderers.length != 0 && state != ExoPlayer.STATE_ENDED) {
} else if (enabledRenderers.length != 0 && state != Player.STATE_ENDED) {
scheduleNextWork(operationStartTimeMs, IDLE_INTERVAL_MS);
} else {
handler.removeMessages(MSG_DO_SOME_WORK);
......@@ -661,7 +661,7 @@ import java.io.IOException;
// Set the internal position to (0,TIME_UNSET) so that a subsequent seek to (0,0) isn't
// ignored.
playbackInfo = new PlaybackInfo(0, C.TIME_UNSET);
setState(ExoPlayer.STATE_ENDED);
setState(Player.STATE_ENDED);
// Reset, but retain the source so that it can still be used should a seek occur.
resetInternal(false);
return;
......@@ -697,7 +697,7 @@ import java.io.IOException;
throws ExoPlaybackException {
stopRenderers();
rebuffering = false;
setState(ExoPlayer.STATE_BUFFERING);
setState(Player.STATE_BUFFERING);
MediaPeriodHolder newPlayingPeriodHolder = null;
if (playingPeriodHolder == null) {
......@@ -787,13 +787,13 @@ import java.io.IOException;
private void stopInternal() {
resetInternal(true);
loadControl.onStopped();
setState(ExoPlayer.STATE_IDLE);
setState(Player.STATE_IDLE);
}
private void releaseInternal() {
resetInternal(true);
loadControl.onReleased();
setState(ExoPlayer.STATE_IDLE);
setState(Player.STATE_IDLE);
synchronized (this) {
released = true;
notifyAll();
......@@ -838,7 +838,7 @@ import java.io.IOException;
for (ExoPlayerMessage message : messages) {
message.target.handleMessage(message.messageType, message.message);
}
if (state == ExoPlayer.STATE_READY || state == ExoPlayer.STATE_BUFFERING) {
if (state == Player.STATE_READY || state == Player.STATE_BUFFERING) {
// The message may have caused something to change that now requires us to do work.
handler.sendEmptyMessage(MSG_DO_SOME_WORK);
}
......@@ -1114,7 +1114,7 @@ import java.io.IOException;
notifySourceInfoRefresh(manifest, processedInitialSeekCount);
// Set the internal position to (0,TIME_UNSET) so that a subsequent seek to (0,0) isn't ignored.
playbackInfo = new PlaybackInfo(0, C.TIME_UNSET);
setState(ExoPlayer.STATE_ENDED);
setState(Player.STATE_ENDED);
// Reset, but retain the source so that it can still be used should a seek occur.
resetInternal(false);
}
......@@ -1427,7 +1427,7 @@ import java.io.IOException;
RendererConfiguration rendererConfiguration =
playingPeriodHolder.trackSelectorResult.rendererConfigurations[i];
// The renderer needs enabling with its new track selection.
boolean playing = playWhenReady && state == ExoPlayer.STATE_READY;
boolean playing = playWhenReady && state == Player.STATE_READY;
// Consider as joining only if the renderer was previously disabled.
boolean joining = !rendererWasEnabledFlags[i] && playing;
// Build an array of formats contained by the selection.
......
......@@ -559,13 +559,13 @@ public abstract class Timeline {
* @param repeatMode A repeat mode.
* @return The index of the next window, or {@link C#INDEX_UNSET} if this is the last window.
*/
public int getNextWindowIndex(int windowIndex, @ExoPlayer.RepeatMode int repeatMode) {
public int getNextWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode) {
switch (repeatMode) {
case ExoPlayer.REPEAT_MODE_OFF:
case Player.REPEAT_MODE_OFF:
return windowIndex == getWindowCount() - 1 ? C.INDEX_UNSET : windowIndex + 1;
case ExoPlayer.REPEAT_MODE_ONE:
case Player.REPEAT_MODE_ONE:
return windowIndex;
case ExoPlayer.REPEAT_MODE_ALL:
case Player.REPEAT_MODE_ALL:
return windowIndex == getWindowCount() - 1 ? 0 : windowIndex + 1;
default:
throw new IllegalStateException();
......@@ -580,13 +580,13 @@ public abstract class Timeline {
* @param repeatMode A repeat mode.
* @return The index of the previous window, or {@link C#INDEX_UNSET} if this is the first window.
*/
public int getPreviousWindowIndex(int windowIndex, @ExoPlayer.RepeatMode int repeatMode) {
public int getPreviousWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode) {
switch (repeatMode) {
case ExoPlayer.REPEAT_MODE_OFF:
case Player.REPEAT_MODE_OFF:
return windowIndex == 0 ? C.INDEX_UNSET : windowIndex - 1;
case ExoPlayer.REPEAT_MODE_ONE:
case Player.REPEAT_MODE_ONE:
return windowIndex;
case ExoPlayer.REPEAT_MODE_ALL:
case Player.REPEAT_MODE_ALL:
return windowIndex == 0 ? getWindowCount() - 1 : windowIndex - 1;
default:
throw new IllegalStateException();
......@@ -601,7 +601,7 @@ public abstract class Timeline {
* @param repeatMode A repeat mode.
* @return Whether the window of the given index is the last window of the timeline.
*/
public final boolean isLastWindow(int windowIndex, @ExoPlayer.RepeatMode int repeatMode) {
public final boolean isLastWindow(int windowIndex, @Player.RepeatMode int repeatMode) {
return getNextWindowIndex(windowIndex, repeatMode) == C.INDEX_UNSET;
}
......@@ -613,7 +613,7 @@ public abstract class Timeline {
* @param repeatMode A repeat mode.
* @return Whether the window of the given index is the first window of the timeline.
*/
public final boolean isFirstWindow(int windowIndex, @ExoPlayer.RepeatMode int repeatMode) {
public final boolean isFirstWindow(int windowIndex, @Player.RepeatMode int repeatMode) {
return getPreviousWindowIndex(windowIndex, repeatMode) == C.INDEX_UNSET;
}
......@@ -672,7 +672,7 @@ public abstract class Timeline {
* @return The index of the next period, or {@link C#INDEX_UNSET} if this is the last period.
*/
public final int getNextPeriodIndex(int periodIndex, Period period, Window window,
@ExoPlayer.RepeatMode int repeatMode) {
@Player.RepeatMode int repeatMode) {
int windowIndex = getPeriod(periodIndex, period).windowIndex;
if (getWindow(windowIndex, window).lastPeriodIndex == periodIndex) {
int nextWindowIndex = getNextWindowIndex(windowIndex, repeatMode);
......@@ -695,7 +695,7 @@ public abstract class Timeline {
* @return Whether the period of the given index is the last period of the timeline.
*/
public final boolean isLastPeriod(int periodIndex, Period period, Window window,
@ExoPlayer.RepeatMode int repeatMode) {
@Player.RepeatMode int repeatMode) {
return getNextPeriodIndex(periodIndex, period, window, repeatMode) == C.INDEX_UNSET;
}
......
......@@ -17,7 +17,7 @@ package com.google.android.exoplayer2.source;
import android.util.Pair;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
/**
......@@ -75,19 +75,19 @@ import com.google.android.exoplayer2.Timeline;
}
@Override
public int getNextWindowIndex(int windowIndex, @ExoPlayer.RepeatMode int repeatMode) {
public int getNextWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode) {
getChildDataByWindowIndex(windowIndex, childDataHolder);
int firstWindowIndexInChild = childDataHolder.firstWindowIndexInChild;
int nextWindowIndexInChild = childDataHolder.timeline.getNextWindowIndex(
windowIndex - firstWindowIndexInChild,
repeatMode == ExoPlayer.REPEAT_MODE_ALL ? ExoPlayer.REPEAT_MODE_OFF : repeatMode);
repeatMode == Player.REPEAT_MODE_ALL ? Player.REPEAT_MODE_OFF : repeatMode);
if (nextWindowIndexInChild != C.INDEX_UNSET) {
return firstWindowIndexInChild + nextWindowIndexInChild;
} else {
firstWindowIndexInChild += childDataHolder.timeline.getWindowCount();
if (firstWindowIndexInChild < getWindowCount()) {
return firstWindowIndexInChild;
} else if (repeatMode == ExoPlayer.REPEAT_MODE_ALL) {
} else if (repeatMode == Player.REPEAT_MODE_ALL) {
return 0;
} else {
return C.INDEX_UNSET;
......@@ -96,18 +96,18 @@ import com.google.android.exoplayer2.Timeline;
}
@Override
public int getPreviousWindowIndex(int windowIndex, @ExoPlayer.RepeatMode int repeatMode) {
public int getPreviousWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode) {
getChildDataByWindowIndex(windowIndex, childDataHolder);
int firstWindowIndexInChild = childDataHolder.firstWindowIndexInChild;
int previousWindowIndexInChild = childDataHolder.timeline.getPreviousWindowIndex(
windowIndex - firstWindowIndexInChild,
repeatMode == ExoPlayer.REPEAT_MODE_ALL ? ExoPlayer.REPEAT_MODE_OFF : repeatMode);
repeatMode == Player.REPEAT_MODE_ALL ? Player.REPEAT_MODE_OFF : repeatMode);
if (previousWindowIndexInChild != C.INDEX_UNSET) {
return firstWindowIndexInChild + previousWindowIndexInChild;
} else {
if (firstWindowIndexInChild > 0) {
return firstWindowIndexInChild - 1;
} else if (repeatMode == ExoPlayer.REPEAT_MODE_ALL) {
} else if (repeatMode == Player.REPEAT_MODE_ALL) {
return getWindowCount() - 1;
} else {
return C.INDEX_UNSET;
......
......@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.source;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.util.Assertions;
......@@ -51,8 +52,7 @@ public final class ConcatenatingMediaSource implements MediaSource {
/**
* @param isRepeatOneAtomic Whether the concatenated media source shall be treated as atomic
* (i.e., repeated in its entirety) when repeat mode is set to
* {@code ExoPlayer.REPEAT_MODE_ONE}.
* (i.e., repeated in its entirety) when repeat mode is set to {@code Player.REPEAT_MODE_ONE}.
* @param mediaSources The {@link MediaSource}s to concatenate. It is valid for the same
* {@link MediaSource} instance to be present more than once in the array.
*/
......@@ -193,17 +193,17 @@ public final class ConcatenatingMediaSource implements MediaSource {
}
@Override
public int getNextWindowIndex(int windowIndex, @ExoPlayer.RepeatMode int repeatMode) {
if (isRepeatOneAtomic && repeatMode == ExoPlayer.REPEAT_MODE_ONE) {
repeatMode = ExoPlayer.REPEAT_MODE_ALL;
public int getNextWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode) {
if (isRepeatOneAtomic && repeatMode == Player.REPEAT_MODE_ONE) {
repeatMode = Player.REPEAT_MODE_ALL;
}
return super.getNextWindowIndex(windowIndex, repeatMode);
}
@Override
public int getPreviousWindowIndex(int windowIndex, @ExoPlayer.RepeatMode int repeatMode) {
if (isRepeatOneAtomic && repeatMode == ExoPlayer.REPEAT_MODE_ONE) {
repeatMode = ExoPlayer.REPEAT_MODE_ALL;
public int getPreviousWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode) {
if (isRepeatOneAtomic && repeatMode == Player.REPEAT_MODE_ONE) {
repeatMode = Player.REPEAT_MODE_ALL;
}
return super.getPreviousWindowIndex(windowIndex, repeatMode);
}
......
......@@ -17,6 +17,7 @@ package com.google.android.exoplayer2.source;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.upstream.Allocator;
import com.google.android.exoplayer2.util.Assertions;
......@@ -161,13 +162,13 @@ public final class LoopingMediaSource implements MediaSource {
}
@Override
public int getNextWindowIndex(int windowIndex, @ExoPlayer.RepeatMode int repeatMode) {
public int getNextWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode) {
int childNextWindowIndex = childTimeline.getNextWindowIndex(windowIndex, repeatMode);
return childNextWindowIndex == C.INDEX_UNSET ? 0 : childNextWindowIndex;
}
@Override
public int getPreviousWindowIndex(int windowIndex, @ExoPlayer.RepeatMode int repeatMode) {
public int getPreviousWindowIndex(int windowIndex, @Player.RepeatMode int repeatMode) {
int childPreviousWindowIndex = childTimeline.getPreviousWindowIndex(windowIndex, repeatMode);
return childPreviousWindowIndex == C.INDEX_UNSET ? getWindowCount() - 1
: childPreviousWindowIndex;
......
......@@ -16,9 +16,7 @@
package com.google.android.exoplayer2.util;
import android.support.annotation.IntDef;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Player;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
......@@ -58,10 +56,10 @@ public final class RepeatModeUtil {
* @param enabledModes Bitmask of enabled modes.
* @return The next repeat mode.
*/
public static @ExoPlayer.RepeatMode int getNextRepeatMode(
@ExoPlayer.RepeatMode int currentMode, int enabledModes) {
public static @Player.RepeatMode int getNextRepeatMode(@Player.RepeatMode int currentMode,
int enabledModes) {
for (int offset = 1; offset <= 2; offset++) {
@ExoPlayer.RepeatMode int proposedMode = (currentMode + offset) % 3;
@Player.RepeatMode int proposedMode = (currentMode + offset) % 3;
if (isRepeatModeEnabled(proposedMode, enabledModes)) {
return proposedMode;
}
......@@ -76,14 +74,13 @@ public final class RepeatModeUtil {
* @param enabledModes The bitmask representing the enabled modes.
* @return {@code true} if enabled.
*/
public static boolean isRepeatModeEnabled(@ExoPlayer.RepeatMode int repeatMode,
int enabledModes) {
public static boolean isRepeatModeEnabled(@Player.RepeatMode int repeatMode, int enabledModes) {
switch (repeatMode) {
case ExoPlayer.REPEAT_MODE_OFF:
case Player.REPEAT_MODE_OFF:
return true;
case ExoPlayer.REPEAT_MODE_ONE:
case Player.REPEAT_MODE_ONE:
return (enabledModes & REPEAT_TOGGLE_MODE_ONE) != 0;
case ExoPlayer.REPEAT_MODE_ALL:
case Player.REPEAT_MODE_ALL:
return (enabledModes & REPEAT_TOGGLE_MODE_ALL) != 0;
default:
return false;
......
......@@ -17,9 +17,9 @@ package com.google.android.exoplayer2.ui;
import android.widget.TextView;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.decoder.DecoderCounters;
......@@ -30,7 +30,7 @@ import com.google.android.exoplayer2.trackselection.TrackSelectionArray;
* A helper class for periodically updating a {@link TextView} with debug information obtained from
* a {@link SimpleExoPlayer}.
*/
public final class DebugTextViewHelper implements Runnable, ExoPlayer.EventListener {
public final class DebugTextViewHelper implements Runnable, Player.EventListener {
private static final int REFRESH_INTERVAL_MS = 1000;
......@@ -74,7 +74,7 @@ public final class DebugTextViewHelper implements Runnable, ExoPlayer.EventListe
textView.removeCallbacks(this);
}
// ExoPlayer.EventListener implementation.
// Player.EventListener implementation.
@Override
public void onLoadingChanged(boolean isLoading) {
......@@ -135,16 +135,16 @@ public final class DebugTextViewHelper implements Runnable, ExoPlayer.EventListe
private String getPlayerStateString() {
String text = "playWhenReady:" + player.getPlayWhenReady() + " playbackState:";
switch (player.getPlaybackState()) {
case ExoPlayer.STATE_BUFFERING:
case Player.STATE_BUFFERING:
text += "buffering";
break;
case ExoPlayer.STATE_ENDED:
case Player.STATE_ENDED:
text += "ended";
break;
case ExoPlayer.STATE_IDLE:
case Player.STATE_IDLE:
text += "idle";
break;
case ExoPlayer.STATE_READY:
case Player.STATE_READY:
text += "ready";
break;
default:
......
......@@ -35,8 +35,8 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.metadata.Metadata;
......@@ -726,8 +726,8 @@ public final class SimpleExoPlayerView extends FrameLayout {
return true;
}
int playbackState = player.getPlaybackState();
return controllerAutoShow && (playbackState == ExoPlayer.STATE_IDLE
|| playbackState == ExoPlayer.STATE_ENDED || !player.getPlayWhenReady());
return controllerAutoShow && (playbackState == Player.STATE_IDLE
|| playbackState == Player.STATE_ENDED || !player.getPlayWhenReady());
}
private void showController(boolean showIndefinitely) {
......@@ -830,7 +830,7 @@ public final class SimpleExoPlayerView extends FrameLayout {
}
private final class ComponentListener implements SimpleExoPlayer.VideoListener,
TextRenderer.Output, ExoPlayer.EventListener {
TextRenderer.Output, Player.EventListener {
// TextRenderer.Output implementation
......@@ -864,7 +864,7 @@ public final class SimpleExoPlayerView extends FrameLayout {
updateForCurrentTrackSelections();
}
// ExoPlayer.EventListener implementation
// Player.EventListener implementation
@Override
public void onLoadingChanged(boolean isLoading) {
......
......@@ -25,6 +25,7 @@ import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.RenderersFactory;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.Timeline;
......@@ -51,7 +52,7 @@ import junit.framework.Assert;
/**
* A {@link HostedTest} for {@link ExoPlayer} playback tests.
*/
public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListener,
public abstract class ExoHostedTest implements HostedTest, Player.EventListener,
AudioRendererEventListener, VideoRendererEventListener {
static {
......@@ -78,7 +79,7 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
private SimpleExoPlayer player;
private Surface surface;
private ExoPlaybackException playerError;
private ExoPlayer.EventListener playerEventListener;
private Player.EventListener playerEventListener;
private boolean playerWasPrepared;
private boolean playerFinished;
private boolean playing;
......@@ -131,9 +132,9 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
}
/**
* Sets an {@link ExoPlayer.EventListener} to listen for ExoPlayer events during the test.
* Sets an {@link Player.EventListener} to listen for ExoPlayer events during the test.
*/
public final void setEventListener(ExoPlayer.EventListener eventListener) {
public final void setEventListener(Player.EventListener eventListener) {
this.playerEventListener = eventListener;
if (player != null) {
player.addListener(eventListener);
......@@ -200,7 +201,7 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
assertPassed(audioDecoderCounters, videoDecoderCounters);
}
// ExoPlayer.EventListener
// Player.EventListener
@Override
public void onLoadingChanged(boolean isLoading) {
......@@ -215,12 +216,12 @@ public abstract class ExoHostedTest implements HostedTest, ExoPlayer.EventListen
@Override
public final void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
Log.d(tag, "state [" + playWhenReady + ", " + playbackState + "]");
playerWasPrepared |= playbackState != ExoPlayer.STATE_IDLE;
if (playbackState == ExoPlayer.STATE_ENDED
|| (playbackState == ExoPlayer.STATE_IDLE && playerWasPrepared)) {
playerWasPrepared |= playbackState != Player.STATE_IDLE;
if (playbackState == Player.STATE_ENDED
|| (playbackState == Player.STATE_IDLE && playerWasPrepared)) {
playerFinished = true;
}
boolean playing = playWhenReady && playbackState == ExoPlayer.STATE_READY;
boolean playing = playWhenReady && playbackState == Player.STATE_READY;
if (!this.playing && playing) {
lastPlayingStartTimeMs = SystemClock.elapsedRealtime();
} else if (this.playing && !playing) {
......
......@@ -22,6 +22,7 @@ import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.source.MediaSource;
......@@ -37,7 +38,7 @@ import junit.framework.Assert;
/**
* Wraps a player with its own handler thread.
*/
public class ExoPlayerWrapper implements ExoPlayer.EventListener {
public class ExoPlayerWrapper implements Player.EventListener {
private final CountDownLatch sourceInfoCountDownLatch;
private final CountDownLatch endedCountDownLatch;
......@@ -142,7 +143,7 @@ public class ExoPlayerWrapper implements ExoPlayer.EventListener {
}
}
// ExoPlayer.EventListener implementation.
// Player.EventListener implementation.
@Override
public void onLoadingChanged(boolean isLoading) {
......@@ -151,7 +152,7 @@ public class ExoPlayerWrapper implements ExoPlayer.EventListener {
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ExoPlayer.STATE_ENDED) {
if (playbackState == Player.STATE_ENDED) {
endedCountDownLatch.countDown();
}
}
......
......@@ -18,7 +18,7 @@ package com.google.android.exoplayer2.testutil;
import static junit.framework.Assert.assertEquals;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Timeline;
import com.google.android.exoplayer2.Timeline.Period;
import com.google.android.exoplayer2.Timeline.Window;
......@@ -71,7 +71,7 @@ public final class TimelineAsserts {
* mode.
*/
public static void assertPreviousWindowIndices(Timeline timeline,
@ExoPlayer.RepeatMode int repeatMode, int... expectedPreviousWindowIndices) {
@Player.RepeatMode int repeatMode, int... expectedPreviousWindowIndices) {
for (int i = 0; i < timeline.getWindowCount(); i++) {
assertEquals(expectedPreviousWindowIndices[i],
timeline.getPreviousWindowIndex(i, repeatMode));
......@@ -82,8 +82,8 @@ public final class TimelineAsserts {
* Asserts that next window indices for each window are set correctly depending on the repeat
* mode.
*/
public static void assertNextWindowIndices(Timeline timeline,
@ExoPlayer.RepeatMode int repeatMode, int... expectedNextWindowIndices) {
public static void assertNextWindowIndices(Timeline timeline, @Player.RepeatMode int repeatMode,
int... expectedNextWindowIndices) {
for (int i = 0; i < timeline.getWindowCount(); i++) {
assertEquals(expectedNextWindowIndices[i],
timeline.getNextWindowIndex(i, repeatMode));
......@@ -119,19 +119,16 @@ public final class TimelineAsserts {
}
assertEquals(expectedWindowIndex, period.windowIndex);
if (i < accumulatedPeriodCounts[expectedWindowIndex + 1] - 1) {
assertEquals(i + 1, timeline.getNextPeriodIndex(i, period, window,
ExoPlayer.REPEAT_MODE_OFF));
assertEquals(i + 1, timeline.getNextPeriodIndex(i, period, window,
ExoPlayer.REPEAT_MODE_ONE));
assertEquals(i + 1, timeline.getNextPeriodIndex(i, period, window,
ExoPlayer.REPEAT_MODE_ALL));
assertEquals(i + 1, timeline.getNextPeriodIndex(i, period, window, Player.REPEAT_MODE_OFF));
assertEquals(i + 1, timeline.getNextPeriodIndex(i, period, window, Player.REPEAT_MODE_ONE));
assertEquals(i + 1, timeline.getNextPeriodIndex(i, period, window, Player.REPEAT_MODE_ALL));
} else {
int nextWindowOff = timeline.getNextWindowIndex(expectedWindowIndex,
ExoPlayer.REPEAT_MODE_OFF);
Player.REPEAT_MODE_OFF);
int nextWindowOne = timeline.getNextWindowIndex(expectedWindowIndex,
ExoPlayer.REPEAT_MODE_ONE);
Player.REPEAT_MODE_ONE);
int nextWindowAll = timeline.getNextWindowIndex(expectedWindowIndex,
ExoPlayer.REPEAT_MODE_ALL);
Player.REPEAT_MODE_ALL);
int nextPeriodOff = nextWindowOff == C.INDEX_UNSET ? C.INDEX_UNSET
: accumulatedPeriodCounts[nextWindowOff];
int nextPeriodOne = nextWindowOne == C.INDEX_UNSET ? C.INDEX_UNSET
......@@ -139,11 +136,11 @@ public final class TimelineAsserts {
int nextPeriodAll = nextWindowAll == C.INDEX_UNSET ? C.INDEX_UNSET
: accumulatedPeriodCounts[nextWindowAll];
assertEquals(nextPeriodOff, timeline.getNextPeriodIndex(i, period, window,
ExoPlayer.REPEAT_MODE_OFF));
Player.REPEAT_MODE_OFF));
assertEquals(nextPeriodOne, timeline.getNextPeriodIndex(i, period, window,
ExoPlayer.REPEAT_MODE_ONE));
Player.REPEAT_MODE_ONE));
assertEquals(nextPeriodAll, timeline.getNextPeriodIndex(i, period, window,
ExoPlayer.REPEAT_MODE_ALL));
Player.REPEAT_MODE_ALL));
}
}
}
......
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