[Android] Expand media only for directories and playlists
Geoffrey Métais
git at videolan.org
Mon May 14 09:52:02 CEST 2018
vlc-android | branch: 3.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon May 14 09:50:04 2018 +0200| [c19fa06131eba41c86cae7d9fc0009535ff23ad1] | committer: Geoffrey Métais
Expand media only for directories and playlists
> https://code.videolan.org/videolan/vlc-android/commit/c19fa06131eba41c86cae7d9fc0009535ff23ad1
---
vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt | 7 +++++--
vlc-android/src/org/videolan/vlc/util/Kextensions.kt | 6 ++++--
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
index 88488b7d8..3d7dcc32c 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlaylistManager.kt
@@ -674,7 +674,10 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
if (isBenchmark) player.setPreviousStats()
if (nextIndex == -1) savePosition(true)
}
- next()
+ launch(UI, CoroutineStart.UNDISPATCHED) {
+ if (player.getMedia().canExpand()) determinePrevAndNextIndices(true)
+ next()
+ }
}
MediaPlayer.Event.EncounteredError -> {
service.showToast(service.getString(
@@ -686,5 +689,5 @@ class PlaylistManager(val service: PlaybackService) : MediaWrapperList.EventList
service.onMediaPlayerEvent(event)
}
- fun isAudioList() = !player.canSwitchToVideo() && mediaList.isAudioList
+ private fun isAudioList() = !player.canSwitchToVideo() && mediaList.isAudioList
}
\ No newline at end of file
diff --git a/vlc-android/src/org/videolan/vlc/util/Kextensions.kt b/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
index ba47d0a7e..d603f0c88 100644
--- a/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
+++ b/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
@@ -1,12 +1,12 @@
package org.videolan.vlc.util
import kotlinx.coroutines.experimental.delay
+import org.videolan.libvlc.Media
import java.io.File
import java.net.URI
import java.net.URISyntaxException
import java.util.*
-
fun String.validateLocation(): Boolean {
var location = this
/* Check if the MRL contains a scheme */
@@ -36,4 +36,6 @@ suspend fun retry (
delay(delayTime)
}
return block() // last attempt
-}
\ No newline at end of file
+}
+
+fun Media?.canExpand() = this != null && (type == Media.Type.Directory || type == Media.Type.Playlist)
More information about the Android
mailing list