diff --git a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java index 2cbef93e4..a0607621e 100644 --- a/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/BasePlayer.java @@ -285,9 +285,11 @@ public abstract class BasePlayer implements destroyPlayer(); unregisterBroadcastReceiver(); + if (mediaSessionManager != null) mediaSessionManager.dispose(); + trackSelector = null; - simpleExoPlayer = null; mediaSessionManager = null; + simpleExoPlayer = null; } /*////////////////////////////////////////////////////////////////////////// @@ -494,22 +496,6 @@ public abstract class BasePlayer implements (manifest == null ? "no manifest" : "available manifest") + ", " + "timeline size = [" + timeline.getWindowCount() + "], " + "reason = [" + reason + "]"); - if (playQueue == null) return; - - switch (reason) { - case Player.TIMELINE_CHANGE_REASON_RESET: // called after #block - case Player.TIMELINE_CHANGE_REASON_PREPARED: // called after #unblock - case Player.TIMELINE_CHANGE_REASON_DYNAMIC: // called after playlist changes - // Ensures MediaSourceManager#update is complete - final boolean isPlaylistStable = timeline.getWindowCount() == playQueue.size(); - // Ensure dynamic/livestream timeline changes does not cause negative position - if (isPlaylistStable && !isCurrentWindowValid() && !isSynchronizing) { - if (DEBUG) Log.d(TAG, "Playback - negative time position reached, " + - "clamping to default position."); - seekToDefault(); - } - break; - } } @Override @@ -598,7 +584,7 @@ public abstract class BasePlayer implements } else if (isSynchronizing && isLive()) { // Is still synchronizing? if (DEBUG) Log.d(TAG, "Playback - Synchronizing livestream to default time"); - seekToDefault(); + //seekToDefault(); } else if (isSynchronizing && presetStartPositionMillis > 0L) { // Has another start position? diff --git a/app/src/main/java/org/schabi/newpipe/player/helper/MediaSessionManager.java b/app/src/main/java/org/schabi/newpipe/player/helper/MediaSessionManager.java index b174ed3ed..63c0bf333 100644 --- a/app/src/main/java/org/schabi/newpipe/player/helper/MediaSessionManager.java +++ b/app/src/main/java/org/schabi/newpipe/player/helper/MediaSessionManager.java @@ -39,10 +39,13 @@ public class MediaSessionManager { return MediaButtonReceiver.handleIntent(mediaSession, intent); } + /** + * Should be called on player destruction to prevent leakage. + * */ public void dispose() { this.sessionConnector.setPlayer(null, null); this.sessionConnector.setQueueNavigator(null); this.mediaSession.setActive(false); this.mediaSession.release(); - } + } } diff --git a/app/src/main/res/layout/player_popup.xml b/app/src/main/res/layout/player_popup.xml index f866cf002..001d43bf6 100644 --- a/app/src/main/res/layout/player_popup.xml +++ b/app/src/main/res/layout/player_popup.xml @@ -111,7 +111,7 @@