[Android] MediaDatabase: add playlistGetItems

Edward Wang git at videolan.org
Mon Dec 8 09:41:55 CET 2014


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Mon Sep  1 13:02:50 2014 -0700| [25815b8fee80d9d990fe13a9c4995bf680ba70de] | committer: Edward Wang

MediaDatabase: add playlistGetItems

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=25815b8fee80d9d990fe13a9c4995bf680ba70de
---

 .../src/org/videolan/vlc/MediaDatabase.java        |   27 ++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/MediaDatabase.java b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
index a1430a3..d40005a 100644
--- a/vlc-android/src/org/videolan/vlc/MediaDatabase.java
+++ b/vlc-android/src/org/videolan/vlc/MediaDatabase.java
@@ -307,6 +307,33 @@ public class MediaDatabase {
         return (count > 0);
     }
 
+   /**
+     * Get all items in the specified playlist.
+     *
+     * @param playlistName Unique name of the playlist
+     * @return Array containing MRLs of the playlist in order, or null on error
+     */
+    public String[] playlistGetItems(String playlistName) {
+        if(!playlistExists(playlistName))
+            return null;
+
+        Cursor c = mDb.query(
+                PLAYLIST_MEDIA_TABLE_NAME,
+                new String[] { PLAYLIST_MEDIA_MEDIALOCATION },
+                PLAYLIST_MEDIA_PLAYLISTNAME + "= ?",
+                new String[] { playlistName }, null, null,
+                PLAYLIST_MEDIA_ORDER + " ASC");
+
+        int count = c.getCount();
+        String ret[] = new String[count]; int i = 0;
+        while(c.moveToNext()) {
+            ret[i] = c.getString(c.getColumnIndex(PLAYLIST_MEDIA_MEDIALOCATION));
+            i++;
+        }
+        c.close();
+        return ret;
+    }
+
     /**
      * Insert an item with location into playlistName at the specified position
      *



More information about the Android mailing list