[Android] Auto: Initialize Medialibrary if needed
Geoffrey Métais
git at videolan.org
Thu Apr 6 16:33:21 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Apr 6 16:12:26 2017 +0200| [7c228a27d1efc0869ff1c9e7b09b837a358d7e50] | committer: Geoffrey Métais
Auto: Initialize Medialibrary if needed
> https://code.videolan.org/videolan/vlc-android/commit/7c228a27d1efc0869ff1c9e7b09b837a358d7e50
---
vlc-android/src/org/videolan/vlc/PlaybackService.java | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index e28850b..14c06cd 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -89,6 +89,7 @@ import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.media.MediaWrapperList;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.FileUtils;
+import org.videolan.vlc.util.Permissions;
import org.videolan.vlc.util.Strings;
import org.videolan.vlc.util.VLCInstance;
import org.videolan.vlc.util.VLCOptions;
@@ -2519,12 +2520,17 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
@Nullable
@Override
public BrowserRoot onGetRoot(@NonNull String clientPackageName, int clientUid, @Nullable Bundle rootHints) {
- return new BrowserRoot(BrowserProvider.ID_ROOT, null);
+ return Permissions.canReadStorage() ? new BrowserRoot(BrowserProvider.ID_ROOT, null) : null;
}
+ boolean mMLInitializing = false;
@Override
public void onLoadChildren(@NonNull final String parentId, @NonNull final Result<List<MediaBrowserCompat.MediaItem>> result) {
result.detach();
+ if (!mMLInitializing && !mMedialibrary.isInitiated() && BrowserProvider.ID_ROOT.equals(parentId)) {
+ startService(new Intent(MediaParsingService.ACTION_INIT, null, this, MediaParsingService.class));
+ mMLInitializing = true;
+ }
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
More information about the Android
mailing list