[Android] Prevent double loading of last playlist
Geoffrey Métais
git at videolan.org
Mon Dec 11 17:47:56 CET 2017
vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Dec 11 14:54:59 2017 +0100| [42e6c12ac6580e9595fbeb25164986313aa59cf8] | committer: Geoffrey Métais
Prevent double loading of last playlist
(cherry picked from commit 5c5574116b41f6574ae6fda2954bde175c5f63b9)
> https://code.videolan.org/videolan/vlc-android/commit/42e6c12ac6580e9595fbeb25164986313aa59cf8
---
.../src/org/videolan/vlc/PlaybackService.java | 23 +++++++++++-----------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 5894ad37d..dbe63d116 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -1643,27 +1643,27 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
});
}
+ private volatile boolean loadingLastPlaylist = false;
public void loadLastPlaylist(final int type) {
+ if (loadingLastPlaylist) return;
+ loadingLastPlaylist = true;
VLCApplication.runBackground(new Runnable() {
@Override
public void run() {
final boolean audio = type == TYPE_AUDIO;
- String[] locations;
+ final String[] locations;
synchronized (PlaybackService.this) {
- String currentMedia = mSettings.getString(audio ? "current_song" : "current_media", "");
- if (currentMedia.equals(""))
- return;
+ final String currentMedia = mSettings.getString(audio ? "current_song" : "current_media", "");
+ if ("".equals(currentMedia)) return;
locations = mSettings.getString(audio ? "audio_list" : "media_list", "").split(" ");
}
- if (locations.length == 0)
- return;
+ if (Util.isArrayEmpty(locations)) return;
final List<MediaWrapper> playList = new ArrayList<>(locations.length);
for (String location : locations) {
String mrl = Uri.decode(location);
MediaWrapper mw = mMedialibrary.getMedia(mrl);
- if (mw == null)
- mw = new MediaWrapper(Uri.parse(mrl));
+ if (mw == null) mw = new MediaWrapper(Uri.parse(mrl));
playList.add(mw);
}
// load playlist
@@ -1680,14 +1680,13 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
if (!audio) {
if (position < playList.size()) {
boolean paused = mSettings.getBoolean(PreferencesActivity.VIDEO_PAUSED, false);
- if (paused)
- playList.get(position).addFlags(MediaWrapper.MEDIA_PAUSED);
+ if (paused) playList.get(position).addFlags(MediaWrapper.MEDIA_PAUSED);
}
float rate = mSettings.getFloat(PreferencesActivity.VIDEO_SPEED, getRate());
- if (rate != 1.0f)
- setRate(rate, false);
+ if (rate != 1.0f) setRate(rate, false);
}
load(playList, position);
+ loadingLastPlaylist = false;
}
});
}
More information about the Android
mailing list