Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to ExoPlayer 2.12.3 #5457

Merged
merged 2 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
14 changes: 10 additions & 4 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,8 @@ public void handleIntent(@NonNull final Intent intent) {
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());
Expand Down Expand Up @@ -1432,7 +1433,8 @@ public float getPlaybackPitch() {
}

public boolean getPlaybackSkipSilence() {
return getPlaybackParameters().skipSilence;
return !exoPlayerIsNull() && simpleExoPlayer.getAudioComponent() != null
&& simpleExoPlayer.getAudioComponent().getSkipSilenceEnabled();
}

public PlaybackParameters getPlaybackParameters() {
Expand All @@ -1457,7 +1459,10 @@ public void setPlaybackParameters(final float speed, final float pitch,

savePlaybackParametersToPrefs(this, roundedSpeed, roundedPitch, skipSilence);
simpleExoPlayer.setPlaybackParameters(
new PlaybackParameters(roundedSpeed, roundedPitch, skipSilence));
new PlaybackParameters(roundedSpeed, roundedPitch));
if (simpleExoPlayer.getAudioComponent() != null) {
simpleExoPlayer.getAudioComponent().setSkipSilenceEnabled(skipSilence);
}
}
//endregion

Expand Down Expand Up @@ -2333,6 +2338,7 @@ public void onPlayerError(@NonNull final ExoPlaybackException error) {
case ExoPlaybackException.TYPE_OUT_OF_MEMORY:
case ExoPlaybackException.TYPE_REMOTE:
case ExoPlaybackException.TYPE_RENDERER:
case ExoPlaybackException.TYPE_TIMEOUT:
default:
showUnrecoverableError(error);
onPlaybackShutdown();
Expand Down Expand Up @@ -3355,7 +3361,7 @@ private void onTextTracksChanged() {
final List<String> availableLanguages = new ArrayList<>(textTracks.length);
for (int i = 0; i < textTracks.length; i++) {
final TrackGroup textTrack = textTracks.get(i);
if (textTrack.length > 0 && textTrack.getFormat(0) != null) {
Redirion marked this conversation as resolved.
Show resolved Hide resolved
if (textTrack.length > 0) {
availableLanguages.add(textTrack.getFormat(0).language);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,14 @@ public boolean retainBackBufferFromKeyframe() {
}

@Override
public boolean shouldContinueLoading(final long bufferedDurationUs,
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,7 @@ public static PlaybackParameters retrievePlaybackParametersFromPrefs(final Playe
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;
Expand Down Expand Up @@ -54,6 +55,14 @@ private boolean canRetry() {
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
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;
Expand Down Expand Up @@ -83,6 +85,38 @@ public void removeEventListener(final MediaSourceEventListener eventListener) {
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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;
Expand All @@ -11,6 +12,14 @@
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() { }
Expand Down