[Android] Keep videos in background in current playlist

Geoffrey Métais git at videolan.org
Tue Oct 16 14:53:43 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Oct 16 14:52:24 2018 +0200| [8bd886d43f2503640f989518ed2f5e9cb53f9437] | committer: Geoffrey Métais

Keep videos in background in current playlist

Only effective when 'Play as audio' has been set

Fix #611

> https://code.videolan.org/videolan/vlc-android/commit/8bd886d43f2503640f989518ed2f5e9cb53f9437
---

 vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index bbd46a6f2..c34399132 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -106,6 +106,7 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
         mediaList.removeEventListener(this)
         mediaList.clear()
         previous.clear()
+        videoBackground = false
         for (media in list) mediaList.add(media)
         if (!hasMedia()) {
             Log.w(TAG, "Warning: empty media list, nothing to play !")
@@ -187,13 +188,14 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
             stop()
             return
         }
-        videoBackground = !player.isVideoPlaying() && player.canSwitchToVideo()
+        videoBackground = videoBackground || (!player.isVideoPlaying() && player.canSwitchToVideo())
         launch { playIndex(currentIndex) }
     }
 
     fun stop(systemExit: Boolean = false) {
         clearABRepeat()
         stopAfter = -1
+        videoBackground = false
         getCurrentMedia()?.let {
             savePosition()
             saveMediaMeta()
@@ -692,7 +694,6 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
             when (event.type) {
                 MediaPlayer.Event.Playing -> {
                     medialibrary.pauseBackgroundOperations()
-                    videoBackground = false
                     val mw = withContext(Dispatchers.IO) {
                         val current = getCurrentMedia()
                         medialibrary.findMedia(current).apply { if (type == -1) type = current?.type ?: -1 }



More information about the Android mailing list