Deprecate LoopingMediaSource.

There is no use case left where we couldn't use a better
alternative (either looping in the player, using the Player
playlist API, or ConcatenatingMediaSource for advanced cases)

PiperOrigin-RevId: 367990981
This commit is contained in:
tonihei 2021-04-12 14:36:22 +01:00 committed by marcbaechinger
parent e499f6d38c
commit aa54aa64b8
4 changed files with 18 additions and 22 deletions

View File

@ -26,16 +26,10 @@ import com.google.android.exoplayer2.audio.AudioSink;
import com.google.android.exoplayer2.audio.DefaultAudioSink;
import com.google.android.exoplayer2.audio.MediaCodecAudioRenderer;
import com.google.android.exoplayer2.metadata.MetadataRenderer;
import com.google.android.exoplayer2.source.ClippingMediaSource;
import com.google.android.exoplayer2.source.ConcatenatingMediaSource;
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
import com.google.android.exoplayer2.source.LoopingMediaSource;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.MediaSourceFactory;
import com.google.android.exoplayer2.source.MergingMediaSource;
import com.google.android.exoplayer2.source.ProgressiveMediaSource;
import com.google.android.exoplayer2.source.ShuffleOrder;
import com.google.android.exoplayer2.source.SingleSampleMediaSource;
import com.google.android.exoplayer2.text.TextRenderer;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.TrackSelector;
@ -61,15 +55,13 @@ import java.util.List;
* Components common to all ExoPlayer implementations are:
*
* <ul>
* <li>A <b>{@link MediaSource}</b> that defines the media to be played, loads the media, and from
* which the loaded media can be read. A MediaSource is injected via {@link
* #setMediaSource(MediaSource)} at the start of playback. The library modules provide default
* implementations for progressive media files ({@link ProgressiveMediaSource}), DASH
* (DashMediaSource), SmoothStreaming (SsMediaSource) and HLS (HlsMediaSource), an
* implementation for loading single media samples ({@link SingleSampleMediaSource}) that's
* most often used for side-loaded subtitle files, and implementations for building more
* complex MediaSources from simpler ones ({@link MergingMediaSource}, {@link
* ConcatenatingMediaSource}, {@link LoopingMediaSource} and {@link ClippingMediaSource}).
* <li><b>{@link MediaSource MediaSources}</b> that define the media to be played, load the media,
* and from which the loaded media can be read. MediaSources are created from {@link MediaItem
* MediaItems} by the {@link MediaSourceFactory} injected in the {@link
* Builder#setMediaSourceFactory Builder}, or can be added directly by methods like {@link
* #setMediaSource(MediaSource)}. The library provides a {@link DefaultMediaSourceFactory} for
* progressive media files, DASH, SmoothStreaming and HLS, including functionality for
* side-loading subtitle files and clipping media.
* <li><b>{@link Renderer}</b>s that render individual components of the media. The library
* provides default implementations for common media types ({@link MediaCodecVideoRenderer},
* {@link MediaCodecAudioRenderer}, {@link TextRenderer} and {@link MetadataRenderer}). A

View File

@ -32,9 +32,15 @@ import java.util.Map;
/**
* Loops a {@link MediaSource} a specified number of times.
*
* <p>Note: To loop a {@link MediaSource} indefinitely, it is usually better to use {@link
* ExoPlayer#setRepeatMode(int)} instead of this class.
* @deprecated To loop a {@link MediaSource} indefinitely, use {@link Player#setRepeatMode(int)}
* instead of this class. To add a {@link MediaSource} a specific number of times to the
* playlist, use {@link ExoPlayer#addMediaSource} in a loop with the same {@link MediaSource}.
* To combine repeated {@link MediaSource} instances into one {@link MediaSource}, for example
* to further wrap it in another {@link MediaSource}, use {@link ConcatenatingMediaSource} with
* the same {@link MediaSource} {@link ConcatenatingMediaSource#addMediaSource added} multiple
* times.
*/
@Deprecated
public final class LoopingMediaSource extends CompositeMediaSource<Void> {
private final MaskingMediaSource maskingMediaSource;

View File

@ -88,7 +88,6 @@ import com.google.android.exoplayer2.robolectric.TestPlayerRunHelper;
import com.google.android.exoplayer2.source.ClippingMediaSource;
import com.google.android.exoplayer2.source.CompositeMediaSource;
import com.google.android.exoplayer2.source.ConcatenatingMediaSource;
import com.google.android.exoplayer2.source.LoopingMediaSource;
import com.google.android.exoplayer2.source.MaskingMediaSource;
import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.source.MediaSource;
@ -3643,7 +3642,6 @@ public final class ExoPlayerTest {
public void seekTo_windowIndexIsReset_deprecated() throws Exception {
FakeTimeline fakeTimeline = new FakeTimeline();
FakeMediaSource mediaSource = new FakeMediaSource(fakeTimeline);
LoopingMediaSource loopingMediaSource = new LoopingMediaSource(mediaSource, 2);
final int[] windowIndex = {C.INDEX_UNSET};
final long[] positionMs = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
final long[] bufferedPositions = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
@ -3677,7 +3675,7 @@ public final class ExoPlayerTest {
})
.build();
new ExoPlayerTestRunner.Builder(context)
.setMediaSources(loopingMediaSource)
.setMediaSources(mediaSource, mediaSource)
.setActionSchedule(actionSchedule)
.build()
.start()
@ -3697,7 +3695,6 @@ public final class ExoPlayerTest {
public void seekTo_windowIndexIsReset() throws Exception {
FakeTimeline fakeTimeline = new FakeTimeline();
FakeMediaSource mediaSource = new FakeMediaSource(fakeTimeline);
LoopingMediaSource loopingMediaSource = new LoopingMediaSource(mediaSource, 2);
final int[] windowIndex = {C.INDEX_UNSET};
final long[] positionMs = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
final long[] bufferedPositions = {C.TIME_UNSET, C.TIME_UNSET, C.TIME_UNSET};
@ -3731,7 +3728,7 @@ public final class ExoPlayerTest {
})
.build();
new ExoPlayerTestRunner.Builder(context)
.setMediaSources(loopingMediaSource)
.setMediaSources(mediaSource, mediaSource)
.setActionSchedule(actionSchedule)
.build()
.start()

View File

@ -30,6 +30,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
/** Unit tests for {@link LoopingMediaSource}. */
@SuppressWarnings("deprecation") // Testing deprecated class.
@RunWith(AndroidJUnit4.class)
public class LoopingMediaSourceTest {