[Android] Setup medialibrary if not yet ready
Geoffrey Métais
git at videolan.org
Thu Apr 20 09:51:36 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Apr 20 09:50:03 2017 +0200| [9c6cb904ffdbc216f8d652dc4d9874ef7035f9e5] | committer: Geoffrey Métais
Setup medialibrary if not yet ready
> https://code.videolan.org/videolan/vlc-android/commit/9c6cb904ffdbc216f8d652dc4d9874ef7035f9e5
---
vlc-android/src/org/videolan/vlc/PlaybackService.java | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 3d02f97..099d73d 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -1203,7 +1203,19 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
}
@Override
- public void onPlayFromSearch(String query, Bundle extras) {
+ public void onPlayFromSearch(final String query, final Bundle extras) {
+ if (!mMedialibrary.isInitiated()) {
+ startService(new Intent(MediaParsingService.ACTION_INIT, null, PlaybackService.this, MediaParsingService.class));
+ final BroadcastReceiver libraryReadyReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ LocalBroadcastManager.getInstance(PlaybackService.this).unregisterReceiver(this);
+ onPlayFromSearch(query, extras);
+ }
+ };
+ LocalBroadcastManager.getInstance(PlaybackService.this).registerReceiver(libraryReadyReceiver, new IntentFilter(VLCApplication.ACTION_MEDIALIBRARY_READY));
+ return;
+ }
mMediaSession.setPlaybackState(new PlaybackStateCompat.Builder().setState(PlaybackStateCompat.STATE_CONNECTING, getTime(), 1.0f).build());
VoiceSearchParams vsp = new VoiceSearchParams(query, extras);
MediaLibraryItem[] items = null;
More information about the Android
mailing list