[Android] Properly stop when playback is not possible

Geoffrey Métais git at videolan.org
Tue Jan 30 11:01:14 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jan 30 11:00:47 2018 +0100| [589e148244462904ba2b4d9e54afb671e61c59b7] | committer: Geoffrey Métais

Properly stop when playback is not possible

> https://code.videolan.org/videolan/vlc-android/commit/589e148244462904ba2b4d9e54afb671e61c59b7
---

 vlc-android/src/org/videolan/vlc/PlaybackService.java     | 1 +
 vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 9 +++++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index e808e7084..029310f47 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -554,6 +554,7 @@ public class PlaybackService extends MediaBrowserServiceCompat{
     };
 
     public void onPlaybackStopped() {
+        hideNotification();
         if (mWakeLock.isHeld()) mWakeLock.release();
         changeAudioFocus(false);
         mMedialibrary.resumeBackgroundOperations();
diff --git a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index b566d46bf..9ae422da4 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -156,7 +156,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
             Log.w(TAG, "Warning: invalid next index, aborted !")
             //Close video player if started
             LocalBroadcastManager.getInstance(ctx).sendBroadcast(Intent(Constants.EXIT_PLAYER))
-            player.stop()
+            stop()
             return
         }
         videoBackground = !player.isVideoPlaying() && player.canSwitchToVideo()
@@ -164,8 +164,10 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
     }
 
     fun stop(systemExit: Boolean = false) {
-        savePosition()
-        if (hasMedia()) saveMediaMeta()
+        if (hasCurrentMedia()) {
+            savePosition()
+            saveMediaMeta()
+        }
         player.releaseMedia()
         mediaList.removeEventListener(this)
         previous.clear()
@@ -175,7 +177,6 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
         else {
             player.restart()
             service.onPlaybackStopped()
-            service.hideNotification()
         }
     }
 



More information about the Android mailing list