[Android] Prevent double load of last playlist
Geoffrey Métais
git at videolan.org
Wed May 31 14:43:09 CEST 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed May 31 14:42:17 2017 +0200| [9528a854b570dfadfe665e71f8cd2fd878eeea92] | committer: Geoffrey Métais
Prevent double load of last playlist
Some devices receive Broadcastreceiver + mediasession command
> https://code.videolan.org/videolan/vlc-android/commit/9528a854b570dfadfe665e71f8cd2fd878eeea92
---
vlc-android/src/org/videolan/vlc/PlaybackService.java | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index c08fcbfa1..43535aa84 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -1496,21 +1496,24 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
sendBroadcast(broadcast);
}
+ BroadcastReceiver mLibraryReceiver = null;
private void loadLastAudioPlaylist() {
+ if (mLibraryReceiver != null)
+ return;
if (mMedialibrary.isInitiated())
loadLastPlaylist(TYPE_AUDIO);
else {
final LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(this);
- BroadcastReceiver receiver = new BroadcastReceiver() {
+ mLibraryReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
lbm.unregisterReceiver(this);
+ mLibraryReceiver = null;
loadLastPlaylist(TYPE_AUDIO);
}
};
- lbm.registerReceiver(receiver, new IntentFilter(VLCApplication.ACTION_MEDIALIBRARY_READY));
+ lbm.registerReceiver(mLibraryReceiver, new IntentFilter(VLCApplication.ACTION_MEDIALIBRARY_READY));
startService(new Intent(MediaParsingService.ACTION_INIT, null, this, MediaParsingService.class));
-
}
}
More information about the Android
mailing list