Update to ExoPlayer 2.11.4
This commit is contained in:
parent
f4f4f062cf
commit
b4ddc8f96c
|
@ -80,7 +80,7 @@ android {
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
androidxLibVersion = '1.0.0'
|
androidxLibVersion = '1.0.0'
|
||||||
exoPlayerLibVersion = '2.10.8'
|
exoPlayerLibVersion = '2.11.4'
|
||||||
roomDbLibVersion = '2.1.0'
|
roomDbLibVersion = '2.1.0'
|
||||||
leakCanaryLibVersion = '1.5.4' //1.6.1
|
leakCanaryLibVersion = '1.5.4' //1.6.1
|
||||||
okHttpLibVersion = '3.12.6'
|
okHttpLibVersion = '3.12.6'
|
||||||
|
|
|
@ -49,7 +49,6 @@ import org.schabi.newpipe.BuildConfig;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
import org.schabi.newpipe.extractor.stream.StreamInfo;
|
||||||
import org.schabi.newpipe.player.event.PlayerEventListener;
|
import org.schabi.newpipe.player.event.PlayerEventListener;
|
||||||
import org.schabi.newpipe.player.helper.LockManager;
|
|
||||||
import org.schabi.newpipe.player.playqueue.PlayQueueItem;
|
import org.schabi.newpipe.player.playqueue.PlayQueueItem;
|
||||||
import org.schabi.newpipe.player.resolver.AudioPlaybackResolver;
|
import org.schabi.newpipe.player.resolver.AudioPlaybackResolver;
|
||||||
import org.schabi.newpipe.player.resolver.MediaSourceTag;
|
import org.schabi.newpipe.player.resolver.MediaSourceTag;
|
||||||
|
@ -91,7 +90,6 @@ public final class BackgroundPlayer extends Service {
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
// Service-Activity Binder
|
// Service-Activity Binder
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
private LockManager lockManager;
|
|
||||||
private SharedPreferences sharedPreferences;
|
private SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -116,7 +114,6 @@ public final class BackgroundPlayer extends Service {
|
||||||
Log.d(TAG, "onCreate() called");
|
Log.d(TAG, "onCreate() called");
|
||||||
}
|
}
|
||||||
notificationManager = ((NotificationManager) getSystemService(NOTIFICATION_SERVICE));
|
notificationManager = ((NotificationManager) getSystemService(NOTIFICATION_SERVICE));
|
||||||
lockManager = new LockManager(this);
|
|
||||||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
assureCorrectAppLanguage(this);
|
assureCorrectAppLanguage(this);
|
||||||
ThemeHelper.setTheme(this);
|
ThemeHelper.setTheme(this);
|
||||||
|
@ -166,9 +163,6 @@ public final class BackgroundPlayer extends Service {
|
||||||
Log.d(TAG, "onClose() called");
|
Log.d(TAG, "onClose() called");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lockManager != null) {
|
|
||||||
lockManager.releaseWifiAndCpu();
|
|
||||||
}
|
|
||||||
if (basePlayerImpl != null) {
|
if (basePlayerImpl != null) {
|
||||||
basePlayerImpl.savePlaybackState();
|
basePlayerImpl.savePlaybackState();
|
||||||
basePlayerImpl.stopActivityBinding();
|
basePlayerImpl.stopActivityBinding();
|
||||||
|
@ -179,7 +173,6 @@ public final class BackgroundPlayer extends Service {
|
||||||
}
|
}
|
||||||
mBinder = null;
|
mBinder = null;
|
||||||
basePlayerImpl = null;
|
basePlayerImpl = null;
|
||||||
lockManager = null;
|
|
||||||
|
|
||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
stopSelf();
|
stopSelf();
|
||||||
|
@ -663,7 +656,6 @@ public final class BackgroundPlayer extends Service {
|
||||||
resetNotification();
|
resetNotification();
|
||||||
updateNotificationThumbnail();
|
updateNotificationThumbnail();
|
||||||
updateNotification(R.drawable.ic_pause_white);
|
updateNotification(R.drawable.ic_pause_white);
|
||||||
lockManager.acquireWifiAndCpu();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -672,7 +664,6 @@ public final class BackgroundPlayer extends Service {
|
||||||
resetNotification();
|
resetNotification();
|
||||||
updateNotificationThumbnail();
|
updateNotificationThumbnail();
|
||||||
updateNotification(R.drawable.ic_play_arrow_white);
|
updateNotification(R.drawable.ic_play_arrow_white);
|
||||||
lockManager.releaseWifiAndCpu();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -687,7 +678,6 @@ public final class BackgroundPlayer extends Service {
|
||||||
}
|
}
|
||||||
updateNotificationThumbnail();
|
updateNotificationThumbnail();
|
||||||
updateNotification(R.drawable.ic_replay_white);
|
updateNotification(R.drawable.ic_replay_white);
|
||||||
lockManager.releaseWifiAndCpu();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,9 @@ import android.widget.Toast;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
import com.google.android.exoplayer2.DefaultRenderersFactory;
|
||||||
import com.google.android.exoplayer2.ExoPlaybackException;
|
import com.google.android.exoplayer2.ExoPlaybackException;
|
||||||
import com.google.android.exoplayer2.ExoPlayerFactory;
|
|
||||||
import com.google.android.exoplayer2.LoadControl;
|
import com.google.android.exoplayer2.LoadControl;
|
||||||
import com.google.android.exoplayer2.PlaybackParameters;
|
import com.google.android.exoplayer2.PlaybackParameters;
|
||||||
import com.google.android.exoplayer2.Player;
|
import com.google.android.exoplayer2.Player;
|
||||||
|
@ -232,14 +232,18 @@ public abstract class BasePlayer implements
|
||||||
|
|
||||||
public void initPlayer(final boolean playOnReady) {
|
public void initPlayer(final boolean playOnReady) {
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "initPlayer() called with: context = [" + context + "]");
|
Log.d(TAG, "initPlayer() called with: playOnReady = [" + playOnReady + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
simpleExoPlayer = ExoPlayerFactory
|
simpleExoPlayer = new SimpleExoPlayer.Builder(context, renderFactory)
|
||||||
.newSimpleInstance(context, renderFactory, trackSelector, loadControl);
|
.setTrackSelector(trackSelector)
|
||||||
|
.setLoadControl(loadControl)
|
||||||
|
.build();
|
||||||
simpleExoPlayer.addListener(this);
|
simpleExoPlayer.addListener(this);
|
||||||
simpleExoPlayer.setPlayWhenReady(playOnReady);
|
simpleExoPlayer.setPlayWhenReady(playOnReady);
|
||||||
simpleExoPlayer.setSeekParameters(PlayerHelper.getSeekParameters(context));
|
simpleExoPlayer.setSeekParameters(PlayerHelper.getSeekParameters(context));
|
||||||
|
simpleExoPlayer.setWakeMode(C.WAKE_MODE_NETWORK);
|
||||||
|
simpleExoPlayer.setHandleAudioBecomingNoisy(true);
|
||||||
|
|
||||||
audioReactor = new AudioReactor(context, simpleExoPlayer);
|
audioReactor = new AudioReactor(context, simpleExoPlayer);
|
||||||
mediaSessionManager = new MediaSessionManager(context, simpleExoPlayer,
|
mediaSessionManager = new MediaSessionManager(context, simpleExoPlayer,
|
||||||
|
@ -666,11 +670,9 @@ public abstract class BasePlayer implements
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTimelineChanged(final Timeline timeline, final Object manifest,
|
public void onTimelineChanged(final Timeline timeline, final int reason) {
|
||||||
@Player.TimelineChangeReason final int reason) {
|
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "ExoPlayer - onTimelineChanged() called with "
|
Log.d(TAG, "ExoPlayer - onTimelineChanged() called with "
|
||||||
+ (manifest == null ? "no manifest" : "available manifest") + ", "
|
|
||||||
+ "timeline size = [" + timeline.getWindowCount() + "], "
|
+ "timeline size = [" + timeline.getWindowCount() + "], "
|
||||||
+ "reason = [" + reason + "]");
|
+ "reason = [" + reason + "]");
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,6 @@ import org.schabi.newpipe.BuildConfig;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||||
import org.schabi.newpipe.player.event.PlayerEventListener;
|
import org.schabi.newpipe.player.event.PlayerEventListener;
|
||||||
import org.schabi.newpipe.player.helper.LockManager;
|
|
||||||
import org.schabi.newpipe.player.helper.PlayerHelper;
|
import org.schabi.newpipe.player.helper.PlayerHelper;
|
||||||
import org.schabi.newpipe.player.resolver.MediaSourceTag;
|
import org.schabi.newpipe.player.resolver.MediaSourceTag;
|
||||||
import org.schabi.newpipe.player.resolver.VideoPlaybackResolver;
|
import org.schabi.newpipe.player.resolver.VideoPlaybackResolver;
|
||||||
|
@ -132,7 +131,6 @@ public final class PopupVideoPlayer extends Service {
|
||||||
private RemoteViews notRemoteView;
|
private RemoteViews notRemoteView;
|
||||||
|
|
||||||
private VideoPlayerImpl playerImpl;
|
private VideoPlayerImpl playerImpl;
|
||||||
private LockManager lockManager;
|
|
||||||
private boolean isPopupClosing = false;
|
private boolean isPopupClosing = false;
|
||||||
|
|
||||||
/*//////////////////////////////////////////////////////////////////////////
|
/*//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -152,7 +150,6 @@ public final class PopupVideoPlayer extends Service {
|
||||||
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
|
||||||
notificationManager = ((NotificationManager) getSystemService(NOTIFICATION_SERVICE));
|
notificationManager = ((NotificationManager) getSystemService(NOTIFICATION_SERVICE));
|
||||||
|
|
||||||
lockManager = new LockManager(this);
|
|
||||||
playerImpl = new VideoPlayerImpl(this);
|
playerImpl = new VideoPlayerImpl(this);
|
||||||
ThemeHelper.setTheme(this);
|
ThemeHelper.setTheme(this);
|
||||||
|
|
||||||
|
@ -378,9 +375,6 @@ public final class PopupVideoPlayer extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
mBinder = null;
|
mBinder = null;
|
||||||
if (lockManager != null) {
|
|
||||||
lockManager.releaseWifiAndCpu();
|
|
||||||
}
|
|
||||||
if (notificationManager != null) {
|
if (notificationManager != null) {
|
||||||
notificationManager.cancel(NOTIFICATION_ID);
|
notificationManager.cancel(NOTIFICATION_ID);
|
||||||
}
|
}
|
||||||
|
@ -914,7 +908,6 @@ public final class PopupVideoPlayer extends Service {
|
||||||
hideControls(DEFAULT_CONTROLS_DURATION, DEFAULT_CONTROLS_HIDE_TIME);
|
hideControls(DEFAULT_CONTROLS_DURATION, DEFAULT_CONTROLS_HIDE_TIME);
|
||||||
|
|
||||||
startForeground(NOTIFICATION_ID, notBuilder.build());
|
startForeground(NOTIFICATION_ID, notBuilder.build());
|
||||||
lockManager.acquireWifiAndCpu();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -932,9 +925,7 @@ public final class PopupVideoPlayer extends Service {
|
||||||
|
|
||||||
resetNotification();
|
resetNotification();
|
||||||
updateNotification(R.drawable.ic_play_arrow_white);
|
updateNotification(R.drawable.ic_play_arrow_white);
|
||||||
|
|
||||||
videoPlayPause.setBackgroundResource(R.drawable.ic_play_arrow_white);
|
videoPlayPause.setBackgroundResource(R.drawable.ic_play_arrow_white);
|
||||||
lockManager.releaseWifiAndCpu();
|
|
||||||
|
|
||||||
stopForeground(false);
|
stopForeground(false);
|
||||||
}
|
}
|
||||||
|
@ -956,9 +947,7 @@ public final class PopupVideoPlayer extends Service {
|
||||||
|
|
||||||
resetNotification();
|
resetNotification();
|
||||||
updateNotification(R.drawable.ic_replay_white);
|
updateNotification(R.drawable.ic_replay_white);
|
||||||
|
|
||||||
videoPlayPause.setBackgroundResource(R.drawable.ic_replay_white);
|
videoPlayPause.setBackgroundResource(R.drawable.ic_replay_white);
|
||||||
lockManager.releaseWifiAndCpu();
|
|
||||||
|
|
||||||
stopForeground(false);
|
stopForeground(false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,9 @@ public class LoadedMediaSource implements ManagedMediaSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepareSource(final SourceInfoRefreshListener listener,
|
public void prepareSource(final MediaSourceCaller mediaSourceCaller,
|
||||||
@Nullable final TransferListener mediaTransferListener) {
|
@Nullable final TransferListener mediaTransferListener) {
|
||||||
source.prepareSource(listener, mediaTransferListener);
|
source.prepareSource(mediaSourceCaller, mediaTransferListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -46,6 +46,11 @@ public class LoadedMediaSource implements ManagedMediaSource {
|
||||||
source.maybeThrowSourceInfoRefreshError();
|
source.maybeThrowSourceInfoRefreshError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable(final MediaSourceCaller caller) {
|
||||||
|
source.enable(caller);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MediaPeriod createPeriod(final MediaPeriodId id, final Allocator allocator,
|
public MediaPeriod createPeriod(final MediaPeriodId id, final Allocator allocator,
|
||||||
final long startPositionUs) {
|
final long startPositionUs) {
|
||||||
|
@ -58,8 +63,13 @@ public class LoadedMediaSource implements ManagedMediaSource {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void releaseSource(final SourceInfoRefreshListener listener) {
|
public void disable(final MediaSourceCaller caller) {
|
||||||
source.releaseSource(listener);
|
source.disable(caller);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void releaseSource(final MediaSourceCaller mediaSourceCaller) {
|
||||||
|
source.releaseSource(mediaSourceCaller);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.schabi.newpipe.player.mediasource;
|
package org.schabi.newpipe.player.mediasource;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.source.MediaSource;
|
import com.google.android.exoplayer2.source.MediaSource;
|
||||||
|
|
||||||
|
@ -27,4 +28,10 @@ public interface ManagedMediaSource extends MediaSource {
|
||||||
* @return whether this source is for the specified stream
|
* @return whether this source is for the specified stream
|
||||||
*/
|
*/
|
||||||
boolean isStreamEqual(@NonNull PlayQueueItem stream);
|
boolean isStreamEqual(@NonNull PlayQueueItem stream);
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
default Object getTag() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class ManagedMediaSourcePlaylist {
|
||||||
@Nullable
|
@Nullable
|
||||||
public ManagedMediaSource get(final int index) {
|
public ManagedMediaSource get(final int index) {
|
||||||
return (index < 0 || index >= size())
|
return (index < 0 || index >= size())
|
||||||
? null : (ManagedMediaSource) internalSource.getMediaSource(index);
|
? null : (ManagedMediaSource) internalSource.getMediaSource(index).getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
|
@ -8,6 +8,7 @@ import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
|
import com.google.android.exoplayer2.RendererCapabilities.Capabilities;
|
||||||
import com.google.android.exoplayer2.source.TrackGroup;
|
import com.google.android.exoplayer2.source.TrackGroup;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
|
||||||
|
@ -48,27 +49,31 @@ public class CustomTrackSelector extends DefaultTrackSelector {
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
protected Pair<TrackSelection.Definition, TextTrackScore> selectTextTrack(
|
protected Pair<TrackSelection.Definition, TextTrackScore> selectTextTrack(
|
||||||
final TrackGroupArray groups, final int[][] formatSupport, final Parameters params,
|
final TrackGroupArray groups,
|
||||||
|
@NonNull final int[][] formatSupport,
|
||||||
|
@NonNull final Parameters params,
|
||||||
@Nullable final String selectedAudioLanguage) {
|
@Nullable final String selectedAudioLanguage) {
|
||||||
TrackGroup selectedGroup = null;
|
TrackGroup selectedGroup = null;
|
||||||
int selectedTrackIndex = C.INDEX_UNSET;
|
int selectedTrackIndex = C.INDEX_UNSET;
|
||||||
int newPipeTrackScore = 0;
|
|
||||||
TextTrackScore selectedTrackScore = null;
|
TextTrackScore selectedTrackScore = null;
|
||||||
|
|
||||||
for (int groupIndex = 0; groupIndex < groups.length; groupIndex++) {
|
for (int groupIndex = 0; groupIndex < groups.length; groupIndex++) {
|
||||||
TrackGroup trackGroup = groups.get(groupIndex);
|
TrackGroup trackGroup = groups.get(groupIndex);
|
||||||
int[] trackFormatSupport = formatSupport[groupIndex];
|
@Capabilities int[] trackFormatSupport = formatSupport[groupIndex];
|
||||||
|
|
||||||
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
|
||||||
if (isSupported(trackFormatSupport[trackIndex],
|
if (isSupported(trackFormatSupport[trackIndex],
|
||||||
params.exceedRendererCapabilitiesIfNecessary)) {
|
params.exceedRendererCapabilitiesIfNecessary)) {
|
||||||
Format format = trackGroup.getFormat(trackIndex);
|
Format format = trackGroup.getFormat(trackIndex);
|
||||||
TextTrackScore trackScore = new TextTrackScore(format, params,
|
TextTrackScore trackScore = new TextTrackScore(format, params,
|
||||||
trackFormatSupport[trackIndex], selectedAudioLanguage);
|
trackFormatSupport[trackIndex], selectedAudioLanguage);
|
||||||
|
|
||||||
if (formatHasLanguage(format, preferredTextLanguage)) {
|
if (formatHasLanguage(format, preferredTextLanguage)) {
|
||||||
selectedGroup = trackGroup;
|
selectedGroup = trackGroup;
|
||||||
selectedTrackIndex = trackIndex;
|
selectedTrackIndex = trackIndex;
|
||||||
selectedTrackScore = trackScore;
|
selectedTrackScore = trackScore;
|
||||||
// found user selected match (perfect!)
|
break; // found user selected match (perfect!)
|
||||||
break;
|
|
||||||
} else if (trackScore.isWithinConstraints && (selectedTrackScore == null
|
} else if (trackScore.isWithinConstraints && (selectedTrackScore == null
|
||||||
|| trackScore.compareTo(selectedTrackScore) > 0)) {
|
|| trackScore.compareTo(selectedTrackScore) > 0)) {
|
||||||
selectedGroup = trackGroup;
|
selectedGroup = trackGroup;
|
||||||
|
|
Loading…
Reference in New Issue