[Android] AudioService: fix open MRL with existing items

Edward Wang git at videolan.org
Sat Jul 27 19:12:14 CEST 2013


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Sat Jul 27 13:11:25 2013 -0400| [5cf82ed6b89496ee1465de7d85ec2b0004d6eb66] | committer: Edward Wang

AudioService: fix open MRL with existing items

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

 vlc-android/jni/libvlcjni.c                        |    8 ++++----
 vlc-android/src/org/videolan/libvlc/LibVLC.java    |    4 ++--
 vlc-android/src/org/videolan/vlc/AudioService.java |    6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
index 8926517..2389b6b 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -719,7 +719,7 @@ static void create_player_and_play(JNIEnv* env, jobject thiz,
     libvlc_media_player_play(mp);
 }
 
-jboolean Java_org_videolan_libvlc_LibVLC_expandMedia(JNIEnv *env, jobject thiz)
+jint Java_org_videolan_libvlc_LibVLC_expandMedia(JNIEnv *env, jobject thiz)
 {
     int current_position = getInt(env, thiz, "mInternalMediaPlayerIndex");
     libvlc_media_list_t* p_mlist = getMediaList(env, thiz);
@@ -744,11 +744,11 @@ jboolean Java_org_videolan_libvlc_LibVLC_expandMedia(JNIEnv *env, jobject thiz)
         if(subitem_count > 0) {
             create_player_and_play(env, thiz,
                 getLong(env, thiz, "mLibVlcInstance"), current_position);
-            return JNI_TRUE;
+            return (jint)current_position;
         } else
-            return JNI_FALSE;
+            return -1;
     } else {
-        return JNI_FALSE;
+        return -1;
     }
 }
 
diff --git a/vlc-android/src/org/videolan/libvlc/LibVLC.java b/vlc-android/src/org/videolan/libvlc/LibVLC.java
index 837aad1..a60ed4e 100644
--- a/vlc-android/src/org/videolan/libvlc/LibVLC.java
+++ b/vlc-android/src/org/videolan/libvlc/LibVLC.java
@@ -577,9 +577,9 @@ public class LibVLC {
       * currently playing media. If there are any subitems, it will
       * expand them and replace the current media.
       *
-      * @return true if a media was expanded, false otherwise
+      * @return the index of the media was expanded, and -1 if no media was expanded
       */
-    public native boolean expandMedia();
+    public native int expandMedia();
 
     /**
      * Return the length of the stream, in milliseconds
diff --git a/vlc-android/src/org/videolan/vlc/AudioService.java b/vlc-android/src/org/videolan/vlc/AudioService.java
index 3e0ca04..72b117a 100644
--- a/vlc-android/src/org/videolan/vlc/AudioService.java
+++ b/vlc-android/src/org/videolan/vlc/AudioService.java
@@ -641,18 +641,18 @@ public class AudioService extends Service {
 
     private void next() {
         // Try to expand any items present
-        if(mLibVLC.expandMedia()) {
+        int pos = mLibVLC.expandMedia();
+        if(pos >= 0) {
             Log.d(TAG, "Found subitems, updating media display");
             ArrayList<String> mediaPathList = new ArrayList<String>();
             mLibVLC.getMediaListItems(mediaPathList);
-            int pos = mMediaList.indexOf(mCurrentMedia);
             mMediaList.clear();
             mPrevious.clear();
 
             for(int i = 0; i < mediaPathList.size(); i++)
                 mMediaList.add(new Media(mediaPathList.get(i), i));
-            mCurrentMedia = mMediaList.get(pos);
             mLibVLCPlaylistActive = true;
+            mCurrentMedia = mMediaList.get(pos);
             final AudioService service = this;
             mVlcEventHandler.postDelayed(new Runnable() {
                 @Override



More information about the Android mailing list