From eea4f0f41c14692d7c566b557813fe1078d39f40 Mon Sep 17 00:00:00 2001 From: Robin Date: Fri, 16 Dec 2022 17:53:56 +0100 Subject: [PATCH] Update ExoPlayer to 2.18.2 --- app/build.gradle | 4 +- .../gesture/PopupPlayerGestureListener.kt | 6 +- .../player/mediasource/LoadedMediaSource.java | 63 ++----------------- 3 files changed, 11 insertions(+), 62 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 72a03e063..f14513c20 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,7 +8,7 @@ plugins { } android { - compileSdk 32 + compileSdk 33 namespace 'org.schabi.newpipe' defaultConfig { @@ -102,7 +102,7 @@ ext { androidxWorkVersion = '2.7.1' icepickVersion = '3.2.0' - exoPlayerVersion = '2.18.1' + exoPlayerVersion = '2.18.2' googleAutoServiceVersion = '1.0.1' groupieVersion = '2.10.1' markwonVersion = '4.6.2' diff --git a/app/src/main/java/org/schabi/newpipe/player/gesture/PopupPlayerGestureListener.kt b/app/src/main/java/org/schabi/newpipe/player/gesture/PopupPlayerGestureListener.kt index 666ea6a46..a540c0ab0 100644 --- a/app/src/main/java/org/schabi/newpipe/player/gesture/PopupPlayerGestureListener.kt +++ b/app/src/main/java/org/schabi/newpipe/player/gesture/PopupPlayerGestureListener.kt @@ -160,15 +160,15 @@ class PopupPlayerGestureListener( } } - override fun onLongPress(e: MotionEvent?) { + override fun onLongPress(e: MotionEvent) { playerUi.updateScreenSize() playerUi.checkPopupPositionBounds() playerUi.changePopupSize(playerUi.screenWidth) } override fun onFling( - e1: MotionEvent?, - e2: MotionEvent?, + e1: MotionEvent, + e2: MotionEvent, velocityX: Float, velocityY: Float ): Boolean { diff --git a/app/src/main/java/org/schabi/newpipe/player/mediasource/LoadedMediaSource.java b/app/src/main/java/org/schabi/newpipe/player/mediasource/LoadedMediaSource.java index 95524cf69..817b048f2 100644 --- a/app/src/main/java/org/schabi/newpipe/player/mediasource/LoadedMediaSource.java +++ b/app/src/main/java/org/schabi/newpipe/player/mediasource/LoadedMediaSource.java @@ -1,27 +1,21 @@ package org.schabi.newpipe.player.mediasource; +import androidx.annotation.NonNull; + import com.google.android.exoplayer2.MediaItem; -import com.google.android.exoplayer2.Timeline; -import com.google.android.exoplayer2.source.CompositeMediaSource; -import com.google.android.exoplayer2.source.MediaPeriod; import com.google.android.exoplayer2.source.MediaSource; -import com.google.android.exoplayer2.upstream.Allocator; -import com.google.android.exoplayer2.upstream.TransferListener; +import com.google.android.exoplayer2.source.WrappingMediaSource; import org.schabi.newpipe.player.mediaitem.MediaItemTag; import org.schabi.newpipe.player.playqueue.PlayQueueItem; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -public class LoadedMediaSource extends CompositeMediaSource implements ManagedMediaSource { - private final MediaSource source; +public class LoadedMediaSource extends WrappingMediaSource implements ManagedMediaSource { private final PlayQueueItem stream; private final MediaItem mediaItem; private final long expireTimestamp; /** - * Uses a {@link CompositeMediaSource} to wrap one or more child {@link MediaSource}s + * Uses a {@link WrappingMediaSource} to wrap one child {@link MediaSource} * containing actual media. This wrapper {@link LoadedMediaSource} holds the expiration * timestamp as a {@link ManagedMediaSource} to allow explicit playlist management under * {@link ManagedMediaSourcePlaylist}. @@ -36,7 +30,7 @@ public class LoadedMediaSource extends CompositeMediaSource implements @NonNull final MediaItemTag tag, @NonNull final PlayQueueItem stream, final long expireTimestamp) { - this.source = source; + super(source); this.stream = stream; this.expireTimestamp = expireTimestamp; @@ -51,51 +45,6 @@ public class LoadedMediaSource extends CompositeMediaSource implements return System.currentTimeMillis() >= expireTimestamp; } - /** - * Delegates the preparation of child {@link MediaSource}s to the - * {@link CompositeMediaSource} wrapper. Since all {@link LoadedMediaSource}s use only - * a single child media, the child id of 0 is always used (sonar doesn't like null as id here). - * - * @param mediaTransferListener A data transfer listener that will be registered by the - * {@link CompositeMediaSource} for child source preparation. - */ - @Override - protected void prepareSourceInternal(@Nullable final TransferListener mediaTransferListener) { - super.prepareSourceInternal(mediaTransferListener); - prepareChildSource(0, source); - } - - /** - * When any child {@link MediaSource} is prepared, the refreshed {@link Timeline} can - * be listened to here. But since {@link LoadedMediaSource} has only a single child source, - * this method is called only once until {@link #releaseSourceInternal()} is called. - *

- * On refresh, the {@link CompositeMediaSource} delegate will be notified with the - * new {@link Timeline}, otherwise {@link #createPeriod(MediaPeriodId, Allocator, long)} - * will not be called and playback may be stalled. - * - * @param id The unique id used to prepare the child source. - * @param mediaSource The child source whose source info has been refreshed. - * @param timeline The new timeline of the child source. - */ - @Override - protected void onChildSourceInfoRefreshed(final Integer id, - final MediaSource mediaSource, - final Timeline timeline) { - refreshSourceInfo(timeline); - } - - @Override - public MediaPeriod createPeriod(final MediaPeriodId id, final Allocator allocator, - final long startPositionUs) { - return source.createPeriod(id, allocator, startPositionUs); - } - - @Override - public void releasePeriod(final MediaPeriod mediaPeriod) { - source.releasePeriod(mediaPeriod); - } - @NonNull @Override public MediaItem getMediaItem() {