Update to ExoPlayer 2.12.3

This commit is contained in:
Robin 2021-01-19 09:27:29 +01:00 committed by Stypox
parent fdb0f01b38
commit eba0b07782
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
7 changed files with 64 additions and 10 deletions

View File

@ -96,7 +96,7 @@ ext {
checkstyleVersion = '8.38'
stethoVersion = '1.5.1'
leakCanaryVersion = '2.5'
exoPlayerVersion = '2.11.8'
exoPlayerVersion = '2.12.3'
androidxLifecycleVersion = '2.2.0'
androidxRoomVersion = '2.3.0-alpha03'
groupieVersion = '2.8.1'

View File

@ -601,7 +601,8 @@ public final class Player implements
final PlaybackParameters savedParameters = retrievePlaybackParametersFromPrefs(this);
final float playbackSpeed = savedParameters.speed;
final float playbackPitch = savedParameters.pitch;
final boolean playbackSkipSilence = savedParameters.skipSilence;
final boolean playbackSkipSilence = getPrefs().getBoolean(getContext().getString(
R.string.playback_skip_silence_key), getPlaybackSkipSilence());
final boolean samePlayQueue = playQueue != null && playQueue.equals(newQueue);
final int repeatMode = intent.getIntExtra(REPEAT_MODE, getRepeatMode());
@ -1432,7 +1433,8 @@ public final class Player implements
}
public boolean getPlaybackSkipSilence() {
return getPlaybackParameters().skipSilence;
return simpleExoPlayer != null
&& simpleExoPlayer.getAudioComponent().getSkipSilenceEnabled();
}
public PlaybackParameters getPlaybackParameters() {
@ -1457,7 +1459,8 @@ public final class Player implements
savePlaybackParametersToPrefs(this, roundedSpeed, roundedPitch, skipSilence);
simpleExoPlayer.setPlaybackParameters(
new PlaybackParameters(roundedSpeed, roundedPitch, skipSilence));
new PlaybackParameters(roundedSpeed, roundedPitch));
simpleExoPlayer.getAudioComponent().setSkipSilenceEnabled(skipSilence);
}
//endregion

View File

@ -80,12 +80,13 @@ public class LoadController implements LoadControl {
}
@Override
public boolean shouldContinueLoading(final long bufferedDurationUs,
final float playbackSpeed) {
public boolean shouldContinueLoading(final long playbackPositionUs,
final long bufferedDurationUs, final float playbackSpeed) {
if (!preloadingEnabled) {
return false;
}
return internalLoadControl.shouldContinueLoading(bufferedDurationUs, playbackSpeed);
return internalLoadControl.shouldContinueLoading(playbackPositionUs, bufferedDurationUs,
playbackSpeed);
}
@Override

View File

@ -494,9 +494,7 @@ public final class PlayerHelper {
R.string.playback_speed_key), player.getPlaybackSpeed());
final float pitch = player.getPrefs().getFloat(player.getContext().getString(
R.string.playback_pitch_key), player.getPlaybackPitch());
final boolean skipSilence = player.getPrefs().getBoolean(player.getContext().getString(
R.string.playback_skip_silence_key), player.getPlaybackSkipSilence());
return new PlaybackParameters(speed, pitch, skipSilence);
return new PlaybackParameters(speed, pitch);
}
public static void savePlaybackParametersToPrefs(final Player player,

View File

@ -5,6 +5,7 @@ import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.source.BaseMediaSource;
import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.upstream.Allocator;
@ -54,6 +55,14 @@ public class FailedMediaSource extends BaseMediaSource implements ManagedMediaSo
return System.currentTimeMillis() >= retryTimestamp;
}
/**
* Returns the {@link MediaItem} whose media is provided by the source.
*/
@Override
public MediaItem getMediaItem() {
return MediaItem.fromUri(playQueueItem.getUrl());
}
@Override
public void maybeThrowSourceInfoRefreshError() throws IOException {
throw new IOException(error);

View File

@ -5,6 +5,8 @@ import android.os.Handler;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.drm.DrmSessionEventListener;
import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.MediaSourceEventListener;
@ -83,6 +85,38 @@ public class LoadedMediaSource implements ManagedMediaSource {
source.removeEventListener(eventListener);
}
/**
* Adds a {@link DrmSessionEventListener} to the list of listeners which are notified of DRM
* events for this media source.
*
* @param handler A handler on the which listener events will be posted.
* @param eventListener The listener to be added.
*/
@Override
public void addDrmEventListener(final Handler handler,
final DrmSessionEventListener eventListener) {
source.addDrmEventListener(handler, eventListener);
}
/**
* Removes a {@link DrmSessionEventListener} from the list of listeners which are notified of
* DRM events for this media source.
*
* @param eventListener The listener to be removed.
*/
@Override
public void removeDrmEventListener(final DrmSessionEventListener eventListener) {
source.removeDrmEventListener(eventListener);
}
/**
* Returns the {@link MediaItem} whose media is provided by the source.
*/
@Override
public MediaItem getMediaItem() {
return source.getMediaItem();
}
@Override
public boolean shouldBeReplacedWith(@NonNull final PlayQueueItem newIdentity,
final boolean isInterruptable) {

View File

@ -3,6 +3,7 @@ package org.schabi.newpipe.player.mediasource;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.MediaItem;
import com.google.android.exoplayer2.source.BaseMediaSource;
import com.google.android.exoplayer2.source.MediaPeriod;
import com.google.android.exoplayer2.upstream.Allocator;
@ -11,6 +12,14 @@ import com.google.android.exoplayer2.upstream.TransferListener;
import org.schabi.newpipe.player.playqueue.PlayQueueItem;
public class PlaceholderMediaSource extends BaseMediaSource implements ManagedMediaSource {
/**
* Returns the {@link MediaItem} whose media is provided by the source.
*/
@Override
public MediaItem getMediaItem() {
return null;
}
// Do nothing, so this will stall the playback
@Override
public void maybeThrowSourceInfoRefreshError() { }