[Android] AudioService: add a function to reload the metadata cache
Edward Wang
git at videolan.org
Thu Aug 29 18:26:35 CEST 2013
vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Thu Aug 29 12:03:21 2013 +0200| [a38f8cc1d5b6f7a42044e523b8d0e6dedf92183a] | committer: Edward Wang
AudioService: add a function to reload the metadata cache
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=a38f8cc1d5b6f7a42044e523b8d0e6dedf92183a
---
vlc-android/src/org/videolan/vlc/AudioService.java | 43 ++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index d7dca92..abb0919 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -1216,4 +1216,47 @@ public class AudioService extends Service {
msg.what = SHOW_TOAST;
mHandler.sendMessage(msg);
}
+
+ private void reloadMetadataCache() {
+ reloadMetadataCache(-1, "");
+ }
+ private void reloadMetadataCache(int skip, String URI) {
+ mMetadataCache.clear();
+ mPrevious.clear();
+ MediaDatabase db = MediaDatabase.getInstance(AudioService.this);
+ for(int i = 0; i < mLibVLC.getMediaList().size(); i++) {
+ String location = mLibVLC.getMediaList().getMRL(i);
+ Media media;
+ if(i != skip) {
+ media = db.getMedia(AudioService.this, location);
+ if(media == null) {
+ if (!validateLocation(location)) {
+ showToast(getResources().getString(R.string.invalid_location, location), Toast.LENGTH_SHORT);
+ continue;
+ }
+ Log.v(TAG, "Creating on-the-fly Media object for " + location);
+ media = new Media(location, false);
+ }
+ } else {
+ // Prevent re-parsing the media, which would mean losing the connection
+ media = new Media(
+ getApplicationContext(),
+ URI,
+ 0,
+ 0,
+ Media.TYPE_AUDIO,
+ null,
+ URI,
+ VLCApplication.getAppContext().getString(R.string.unknown_artist),
+ VLCApplication.getAppContext().getString(R.string.unknown_genre),
+ VLCApplication.getAppContext().getString(R.string.unknown_album),
+ 0,
+ 0,
+ "",
+ -1,
+ -1);
+ }
+ mMetadataCache.add(media);
+ }
+ }
}
More information about the Android
mailing list