Merge pull request #3513 from Stypox/exoplayer

Update to ExoPlayer 2.11.4
pull/3613/head
Stypox 2020-05-17 22:02:19 +02:00 zatwierdzone przez GitHub
commit c05467fb92
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
8 zmienionych plików z 42 dodań i 39 usunięć

Wyświetl plik

@ -81,7 +81,7 @@ android {
ext {
androidxLibVersion = '1.0.0'
exoPlayerLibVersion = '2.10.8'
exoPlayerLibVersion = '2.11.4'
roomDbLibVersion = '2.1.0'
leakCanaryLibVersion = '1.5.4' //1.6.1
okHttpLibVersion = '3.12.6'

Wyświetl plik

@ -49,7 +49,6 @@ import org.schabi.newpipe.BuildConfig;
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.stream.StreamInfo;
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.resolver.AudioPlaybackResolver;
import org.schabi.newpipe.player.resolver.MediaSourceTag;
@ -91,7 +90,6 @@ public final class BackgroundPlayer extends Service {
/*//////////////////////////////////////////////////////////////////////////
// Service-Activity Binder
//////////////////////////////////////////////////////////////////////////*/
private LockManager lockManager;
private SharedPreferences sharedPreferences;
/*//////////////////////////////////////////////////////////////////////////
@ -116,7 +114,6 @@ public final class BackgroundPlayer extends Service {
Log.d(TAG, "onCreate() called");
}
notificationManager = ((NotificationManager) getSystemService(NOTIFICATION_SERVICE));
lockManager = new LockManager(this);
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
assureCorrectAppLanguage(this);
ThemeHelper.setTheme(this);
@ -166,9 +163,6 @@ public final class BackgroundPlayer extends Service {
Log.d(TAG, "onClose() called");
}
if (lockManager != null) {
lockManager.releaseWifiAndCpu();
}
if (basePlayerImpl != null) {
basePlayerImpl.savePlaybackState();
basePlayerImpl.stopActivityBinding();
@ -179,7 +173,6 @@ public final class BackgroundPlayer extends Service {
}
mBinder = null;
basePlayerImpl = null;
lockManager = null;
stopForeground(true);
stopSelf();
@ -663,7 +656,6 @@ public final class BackgroundPlayer extends Service {
resetNotification();
updateNotificationThumbnail();
updateNotification(R.drawable.ic_pause_white);
lockManager.acquireWifiAndCpu();
}
@Override
@ -672,7 +664,6 @@ public final class BackgroundPlayer extends Service {
resetNotification();
updateNotificationThumbnail();
updateNotification(R.drawable.ic_play_arrow_white);
lockManager.releaseWifiAndCpu();
}
@Override
@ -687,7 +678,6 @@ public final class BackgroundPlayer extends Service {
}
updateNotificationThumbnail();
updateNotification(R.drawable.ic_replay_white);
lockManager.releaseWifiAndCpu();
}
}
}

Wyświetl plik

@ -35,9 +35,9 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.LoadControl;
import com.google.android.exoplayer2.PlaybackParameters;
import com.google.android.exoplayer2.Player;
@ -232,14 +232,18 @@ public abstract class BasePlayer implements
public void initPlayer(final boolean playOnReady) {
if (DEBUG) {
Log.d(TAG, "initPlayer() called with: context = [" + context + "]");
Log.d(TAG, "initPlayer() called with: playOnReady = [" + playOnReady + "]");
}
simpleExoPlayer = ExoPlayerFactory
.newSimpleInstance(context, renderFactory, trackSelector, loadControl);
simpleExoPlayer = new SimpleExoPlayer.Builder(context, renderFactory)
.setTrackSelector(trackSelector)
.setLoadControl(loadControl)
.build();
simpleExoPlayer.addListener(this);
simpleExoPlayer.setPlayWhenReady(playOnReady);
simpleExoPlayer.setSeekParameters(PlayerHelper.getSeekParameters(context));
simpleExoPlayer.setWakeMode(C.WAKE_MODE_NETWORK);
simpleExoPlayer.setHandleAudioBecomingNoisy(true);
audioReactor = new AudioReactor(context, simpleExoPlayer);
mediaSessionManager = new MediaSessionManager(context, simpleExoPlayer,
@ -666,11 +670,9 @@ public abstract class BasePlayer implements
//////////////////////////////////////////////////////////////////////////*/
@Override
public void onTimelineChanged(final Timeline timeline, final Object manifest,
@Player.TimelineChangeReason final int reason) {
public void onTimelineChanged(final Timeline timeline, final int reason) {
if (DEBUG) {
Log.d(TAG, "ExoPlayer - onTimelineChanged() called with "
+ (manifest == null ? "no manifest" : "available manifest") + ", "
+ "timeline size = [" + timeline.getWindowCount() + "], "
+ "reason = [" + reason + "]");
}

Wyświetl plik

@ -68,7 +68,6 @@ import org.schabi.newpipe.BuildConfig;
import org.schabi.newpipe.R;
import org.schabi.newpipe.extractor.stream.VideoStream;
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.resolver.MediaSourceTag;
import org.schabi.newpipe.player.resolver.VideoPlaybackResolver;
@ -132,7 +131,6 @@ public final class PopupVideoPlayer extends Service {
private RemoteViews notRemoteView;
private VideoPlayerImpl playerImpl;
private LockManager lockManager;
private boolean isPopupClosing = false;
/*//////////////////////////////////////////////////////////////////////////
@ -152,7 +150,6 @@ public final class PopupVideoPlayer extends Service {
windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
notificationManager = ((NotificationManager) getSystemService(NOTIFICATION_SERVICE));
lockManager = new LockManager(this);
playerImpl = new VideoPlayerImpl(this);
ThemeHelper.setTheme(this);
@ -378,9 +375,6 @@ public final class PopupVideoPlayer extends Service {
}
mBinder = null;
if (lockManager != null) {
lockManager.releaseWifiAndCpu();
}
if (notificationManager != null) {
notificationManager.cancel(NOTIFICATION_ID);
}
@ -914,7 +908,6 @@ public final class PopupVideoPlayer extends Service {
hideControls(DEFAULT_CONTROLS_DURATION, DEFAULT_CONTROLS_HIDE_TIME);
startForeground(NOTIFICATION_ID, notBuilder.build());
lockManager.acquireWifiAndCpu();
}
@Override
@ -932,9 +925,7 @@ public final class PopupVideoPlayer extends Service {
resetNotification();
updateNotification(R.drawable.ic_play_arrow_white);
videoPlayPause.setBackgroundResource(R.drawable.ic_play_arrow_white);
lockManager.releaseWifiAndCpu();
stopForeground(false);
}
@ -956,9 +947,7 @@ public final class PopupVideoPlayer extends Service {
resetNotification();
updateNotification(R.drawable.ic_replay_white);
videoPlayPause.setBackgroundResource(R.drawable.ic_replay_white);
lockManager.releaseWifiAndCpu();
stopForeground(false);
}

Wyświetl plik

@ -36,9 +36,9 @@ public class LoadedMediaSource implements ManagedMediaSource {
}
@Override
public void prepareSource(final SourceInfoRefreshListener listener,
public void prepareSource(final MediaSourceCaller mediaSourceCaller,
@Nullable final TransferListener mediaTransferListener) {
source.prepareSource(listener, mediaTransferListener);
source.prepareSource(mediaSourceCaller, mediaTransferListener);
}
@Override
@ -46,6 +46,11 @@ public class LoadedMediaSource implements ManagedMediaSource {
source.maybeThrowSourceInfoRefreshError();
}
@Override
public void enable(final MediaSourceCaller caller) {
source.enable(caller);
}
@Override
public MediaPeriod createPeriod(final MediaPeriodId id, final Allocator allocator,
final long startPositionUs) {
@ -58,8 +63,13 @@ public class LoadedMediaSource implements ManagedMediaSource {
}
@Override
public void releaseSource(final SourceInfoRefreshListener listener) {
source.releaseSource(listener);
public void disable(final MediaSourceCaller caller) {
source.disable(caller);
}
@Override
public void releaseSource(final MediaSourceCaller mediaSourceCaller) {
source.releaseSource(mediaSourceCaller);
}
@Override

Wyświetl plik

@ -1,6 +1,7 @@
package org.schabi.newpipe.player.mediasource;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
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
*/
boolean isStreamEqual(@NonNull PlayQueueItem stream);
@Nullable
@Override
default Object getTag() {
return this;
}
}

Wyświetl plik

@ -35,7 +35,7 @@ public class ManagedMediaSourcePlaylist {
@Nullable
public ManagedMediaSource get(final int index) {
return (index < 0 || index >= size())
? null : (ManagedMediaSource) internalSource.getMediaSource(index);
? null : (ManagedMediaSource) internalSource.getMediaSource(index).getTag();
}
@NonNull

Wyświetl plik

@ -8,6 +8,7 @@ import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
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.TrackGroupArray;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
@ -48,27 +49,31 @@ public class CustomTrackSelector extends DefaultTrackSelector {
@Override
@Nullable
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) {
TrackGroup selectedGroup = null;
int selectedTrackIndex = C.INDEX_UNSET;
int newPipeTrackScore = 0;
TextTrackScore selectedTrackScore = null;
for (int groupIndex = 0; groupIndex < groups.length; groupIndex++) {
TrackGroup trackGroup = groups.get(groupIndex);
int[] trackFormatSupport = formatSupport[groupIndex];
@Capabilities int[] trackFormatSupport = formatSupport[groupIndex];
for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
if (isSupported(trackFormatSupport[trackIndex],
params.exceedRendererCapabilitiesIfNecessary)) {
Format format = trackGroup.getFormat(trackIndex);
TextTrackScore trackScore = new TextTrackScore(format, params,
trackFormatSupport[trackIndex], selectedAudioLanguage);
if (formatHasLanguage(format, preferredTextLanguage)) {
selectedGroup = trackGroup;
selectedTrackIndex = trackIndex;
selectedTrackScore = trackScore;
// found user selected match (perfect!)
break;
break; // found user selected match (perfect!)
} else if (trackScore.isWithinConstraints && (selectedTrackScore == null
|| trackScore.compareTo(selectedTrackScore) > 0)) {
selectedGroup = trackGroup;