Skip to content

Commit 73aebc1

Browse files
authored
Merge pull request TeamNewPipe#9847 from Redirion/exo183
Update to ExoPlayer 2.18.3
2 parents 3cb76e4 + 5560cea commit 73aebc1

2 files changed

Lines changed: 7 additions & 58 deletions

File tree

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ ext {
106106
androidxWorkVersion = '2.7.1'
107107

108108
icepickVersion = '3.2.0'
109-
exoPlayerVersion = '2.18.1'
109+
exoPlayerVersion = '2.18.3'
110110
googleAutoServiceVersion = '1.0.1'
111111
groupieVersion = '2.10.1'
112112
markwonVersion = '4.6.2'

app/src/main/java/org/schabi/newpipe/player/mediasource/LoadedMediaSource.java

Lines changed: 6 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
11
package org.schabi.newpipe.player.mediasource;
22

3+
import androidx.annotation.NonNull;
4+
35
import com.google.android.exoplayer2.MediaItem;
4-
import com.google.android.exoplayer2.Timeline;
5-
import com.google.android.exoplayer2.source.CompositeMediaSource;
6-
import com.google.android.exoplayer2.source.MediaPeriod;
76
import com.google.android.exoplayer2.source.MediaSource;
8-
import com.google.android.exoplayer2.upstream.Allocator;
9-
import com.google.android.exoplayer2.upstream.TransferListener;
7+
import com.google.android.exoplayer2.source.WrappingMediaSource;
108

119
import org.schabi.newpipe.player.mediaitem.MediaItemTag;
1210
import org.schabi.newpipe.player.playqueue.PlayQueueItem;
1311

14-
import androidx.annotation.NonNull;
15-
import androidx.annotation.Nullable;
16-
17-
public class LoadedMediaSource extends CompositeMediaSource<Integer> implements ManagedMediaSource {
18-
private final MediaSource source;
12+
public class LoadedMediaSource extends WrappingMediaSource implements ManagedMediaSource {
1913
private final PlayQueueItem stream;
2014
private final MediaItem mediaItem;
2115
private final long expireTimestamp;
2216

2317
/**
24-
* Uses a {@link CompositeMediaSource} to wrap one or more child {@link MediaSource}s
18+
* Uses a {@link WrappingMediaSource} to wrap one child {@link MediaSource}s
2519
* containing actual media. This wrapper {@link LoadedMediaSource} holds the expiration
2620
* timestamp as a {@link ManagedMediaSource} to allow explicit playlist management under
2721
* {@link ManagedMediaSourcePlaylist}.
@@ -36,7 +30,7 @@ public LoadedMediaSource(@NonNull final MediaSource source,
3630
@NonNull final MediaItemTag tag,
3731
@NonNull final PlayQueueItem stream,
3832
final long expireTimestamp) {
39-
this.source = source;
33+
super(source);
4034
this.stream = stream;
4135
this.expireTimestamp = expireTimestamp;
4236

@@ -51,51 +45,6 @@ private boolean isExpired() {
5145
return System.currentTimeMillis() >= expireTimestamp;
5246
}
5347

54-
/**
55-
* Delegates the preparation of child {@link MediaSource}s to the
56-
* {@link CompositeMediaSource} wrapper. Since all {@link LoadedMediaSource}s use only
57-
* a single child media, the child id of 0 is always used (sonar doesn't like null as id here).
58-
*
59-
* @param mediaTransferListener A data transfer listener that will be registered by the
60-
* {@link CompositeMediaSource} for child source preparation.
61-
*/
62-
@Override
63-
protected void prepareSourceInternal(@Nullable final TransferListener mediaTransferListener) {
64-
super.prepareSourceInternal(mediaTransferListener);
65-
prepareChildSource(0, source);
66-
}
67-
68-
/**
69-
* When any child {@link MediaSource} is prepared, the refreshed {@link Timeline} can
70-
* be listened to here. But since {@link LoadedMediaSource} has only a single child source,
71-
* this method is called only once until {@link #releaseSourceInternal()} is called.
72-
* <br><br>
73-
* On refresh, the {@link CompositeMediaSource} delegate will be notified with the
74-
* new {@link Timeline}, otherwise {@link #createPeriod(MediaPeriodId, Allocator, long)}
75-
* will not be called and playback may be stalled.
76-
*
77-
* @param id The unique id used to prepare the child source.
78-
* @param mediaSource The child source whose source info has been refreshed.
79-
* @param timeline The new timeline of the child source.
80-
*/
81-
@Override
82-
protected void onChildSourceInfoRefreshed(final Integer id,
83-
final MediaSource mediaSource,
84-
final Timeline timeline) {
85-
refreshSourceInfo(timeline);
86-
}
87-
88-
@Override
89-
public MediaPeriod createPeriod(final MediaPeriodId id, final Allocator allocator,
90-
final long startPositionUs) {
91-
return source.createPeriod(id, allocator, startPositionUs);
92-
}
93-
94-
@Override
95-
public void releasePeriod(final MediaPeriod mediaPeriod) {
96-
source.releasePeriod(mediaPeriod);
97-
}
98-
9948
@NonNull
10049
@Override
10150
public MediaItem getMediaItem() {

0 commit comments

Comments
 (0)