[Android] [PATCH 1/3] MediaPlayer: add setAudioOutputDevice

Thomas Guillem thomas at gllm.fr
Tue Jul 7 18:23:22 CEST 2015


---
 libvlc/jni/libvlcjni-mediaplayer.c              | 23 +++++++++++++++++++++++
 libvlc/src/org/videolan/libvlc/MediaPlayer.java | 10 ++++++++++
 2 files changed, 33 insertions(+)

diff --git a/libvlc/jni/libvlcjni-mediaplayer.c b/libvlc/jni/libvlcjni-mediaplayer.c
index 2085cab..e27cbc0 100644
--- a/libvlc/jni/libvlcjni-mediaplayer.c
+++ b/libvlc/jni/libvlcjni-mediaplayer.c
@@ -482,6 +482,29 @@ Java_org_videolan_libvlc_MediaPlayer_nativeSetAudioOutput(JNIEnv *env,
     return i_ret == 0 ? true : false;
 }
 
+jboolean
+Java_org_videolan_libvlc_MediaPlayer_nativeSetAudioOutputDevice(JNIEnv *env,
+                                                                jobject thiz,
+                                                                jstring jid)
+{
+    const char* psz_id;
+    int i_ret;
+    vlcjni_object *p_obj = VLCJniObject_getInstance(env, thiz);
+
+    if (!p_obj)
+        return false;
+
+    if (!jid || !(psz_id = (*env)->GetStringUTFChars(env, jid, 0)))
+    {
+        throw_IllegalArgumentException(env, "aout invalid");
+        return false;
+    }
+
+    libvlc_audio_output_device_set(p_obj->u.p_mp, NULL, psz_id);
+    (*env)->ReleaseStringUTFChars(env, jid, psz_id);
+    return true;
+}
+
 static jobject
 mediaplayer_title_to_object(JNIEnv *env, libvlc_title_description_t *p_title)
 {
diff --git a/libvlc/src/org/videolan/libvlc/MediaPlayer.java b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
index 8e9d24e..9ae1a74 100644
--- a/libvlc/src/org/videolan/libvlc/MediaPlayer.java
+++ b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
@@ -447,6 +447,16 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
     }
 
     /**
+     * Configures an explicit audio output device.
+     * Audio output will be moved to the device specified by the device identifier string.
+     *
+     * @return true on success.
+     */
+    public synchronized boolean setAudioOutputDevice(String id) {
+        return nativeSetAudioOutputDevice(id);
+    }
+
+    /**
      * Get the full description of available titles.
      *
      * @return the list of titles
-- 
2.1.4



More information about the Android mailing list