[Android] LibVLC: update MediaPlayer.addSlave

Thomas Guillem git at videolan.org
Thu Jun 9 23:49:39 CEST 2016


vlc-android | branch: 2.0.x | Thomas Guillem <thomas at gllm.fr> | Tue Jun  7 18:22:34 2016 +0200| [72b094f93bc99b680a0ec6f848561910f9a8aabb] | committer: Jean-Baptiste Kempf

LibVLC: update MediaPlayer.addSlave

> https://code.videolan.org/videolan/vlc-android/commit/72b094f93bc99b680a0ec6f848561910f9a8aabb
---

 libvlc/jni/libvlcjni-mediaplayer.c                    |  4 ++--
 libvlc/src/org/videolan/libvlc/MediaPlayer.java       | 10 +++++-----
 libvlc/src/org/videolan/libvlc/media/MediaPlayer.java |  5 ++---
 vlc-android/src/org/videolan/vlc/PlaybackService.java | 16 +++++++++++++---
 4 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/libvlc/jni/libvlcjni-mediaplayer.c b/libvlc/jni/libvlcjni-mediaplayer.c
index b1abe99..b24ca59 100644
--- a/libvlc/jni/libvlcjni-mediaplayer.c
+++ b/libvlc/jni/libvlcjni-mediaplayer.c
@@ -884,7 +884,7 @@ Java_org_videolan_libvlc_MediaPlayer_nativeSetSpuDelay(JNIEnv *env,
 jboolean
 Java_org_videolan_libvlc_MediaPlayer_nativeAddSlave(JNIEnv *env,
                                                     jobject thiz, jint type,
-                                                    jstring jmrl)
+                                                    jstring jmrl, jboolean select)
 {
     vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz);
     const char* psz_mrl;
@@ -898,7 +898,7 @@ Java_org_videolan_libvlc_MediaPlayer_nativeAddSlave(JNIEnv *env,
         return false;
     }
 
-    jboolean ret = libvlc_media_player_add_slave(p_obj->u.p_mp, type, psz_mrl) == 0;
+    jboolean ret = libvlc_media_player_add_slave(p_obj->u.p_mp, type, psz_mrl, select) == 0;
 
     (*env)->ReleaseStringUTFChars(env, jmrl, psz_mrl);
     return ret;
diff --git a/libvlc/src/org/videolan/libvlc/MediaPlayer.java b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
index 7c770be..145fdbd 100644
--- a/libvlc/src/org/videolan/libvlc/MediaPlayer.java
+++ b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
@@ -719,8 +719,8 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
      * @param uri a valid RFC 2396 Uri
      * @return true on success.
      */
-    public boolean addSlave(int type, Uri uri) {
-        return nativeAddSlave(type, Media.locationFromUri(uri));
+    public boolean addSlave(int type, Uri uri, boolean select) {
+        return nativeAddSlave(type, Media.locationFromUri(uri), select);
     }
 
     /**
@@ -730,8 +730,8 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
      * @param path a local path
      * @return true on success.
      */
-    public boolean addSlave(int type, String path) {
-        return addSlave(type, Uri.fromFile(new File(path)));
+    public boolean addSlave(int type, String path, boolean select) {
+        return addSlave(type, Uri.fromFile(new File(path)), select);
     }
 
     /**
@@ -887,6 +887,6 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
     private native boolean nativeSetSpuTrack(int index);
     private native long nativeGetSpuDelay();
     private native boolean nativeSetSpuDelay(long delay);
-    private native boolean nativeAddSlave(int type, String location);
+    private native boolean nativeAddSlave(int type, String location, boolean select);
     private native boolean nativeSetEqualizer(Equalizer equalizer);
 }
diff --git a/libvlc/src/org/videolan/libvlc/media/MediaPlayer.java b/libvlc/src/org/videolan/libvlc/media/MediaPlayer.java
index af5c509..a42ec29 100644
--- a/libvlc/src/org/videolan/libvlc/media/MediaPlayer.java
+++ b/libvlc/src/org/videolan/libvlc/media/MediaPlayer.java
@@ -279,12 +279,11 @@ public class MediaPlayer
     public static final String MEDIA_MIMETYPE_TEXT_SUBRIP = "application/x-subrip";
 
     public void addTimedTextSource(String path, String mimeType) {
-        mMediaPlayer.addSlave(Media.Slave.Type.Subtitle, path);
+        mMediaPlayer.addSlave(Media.Slave.Type.Subtitle, path, false);
     }
 
-    // FIXME: This is incorrect, since libVLC can only add local subtitles
     public void addTimedTextSource(Context context, Uri uri, String mimeType) {
-        mMediaPlayer.addSlave(Media.Slave.Type.Subtitle, uri);
+        mMediaPlayer.addSlave(Media.Slave.Type.Subtitle, uri, false);
     }
 
     public void addTimedTextSource(FileDescriptor fd, String mimeType)
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 8dad3db..7c0126a 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -1728,7 +1728,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
             public void run() {
                 final ArrayList<Media.Slave> list = MediaDatabase.getInstance().getSlaves(mw.getLocation());
                 for (Media.Slave slave : list)
-                    mMediaPlayer.addSlave(slave.type, Uri.parse(slave.uri));
+                    mMediaPlayer.addSlave(slave.type, Uri.parse(slave.uri), false);
             }
         });
 
@@ -2044,13 +2044,23 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
     }
 
     @MainThread
+    public boolean addSubtitleTrack(String path, boolean select) {
+        return mMediaPlayer.addSlave(Media.Slave.Type.Subtitle, path, select);
+    }
+
+    @MainThread
+    public boolean addSubtitleTrack(Uri uri,boolean select) {
+        return mMediaPlayer.addSlave(Media.Slave.Type.Subtitle, uri, select);
+    }
+
+    @MainThread
     public boolean addSubtitleTrack(String path) {
-        return mMediaPlayer.addSlave(Media.Slave.Type.Subtitle, path);
+        return addSubtitleTrack(path, false);
     }
 
     @MainThread
     public boolean addSubtitleTrack(Uri uri) {
-        return mMediaPlayer.addSlave(Media.Slave.Type.Subtitle, uri);
+        return addSubtitleTrack(uri, false);
     }
 
     @MainThread



More information about the Android mailing list