[Android] LibVLC: MediaPlayer: add forceAudioDigitalEncodings()

Thomas Guillem git at videolan.org
Mon Mar 26 18:23:42 CEST 2018


vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Mar 26 15:07:24 2018 +0200| [b8fd87d28407c2a62cf08377a5f845cbb3e1ee2c] | committer: Geoffrey Métais

LibVLC: MediaPlayer: add forceAudioDigitalEncodings()

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

 libvlc/src/org/videolan/libvlc/MediaPlayer.java | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/libvlc/src/org/videolan/libvlc/MediaPlayer.java b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
index 8bb52e2fa..8f00202b3 100644
--- a/libvlc/src/org/videolan/libvlc/MediaPlayer.java
+++ b/libvlc/src/org/videolan/libvlc/MediaPlayer.java
@@ -764,6 +764,28 @@ public class MediaPlayer extends VLCObject<MediaPlayer.Event> {
         return true;
     }
 
+    /** Convenient method for {@link #setAudioOutputDevice}
+     *
+     * @param encodings list of encodings to play via passthrough (see AudioFormat.ENCODING_*),
+     *                  null to don't force any.
+     * @return true on success
+     */
+    public synchronized boolean forceAudioDigitalEncodings(int []encodings) {
+        if (!isAudioTrack())
+            return false;
+
+        if (encodings.length == 0)
+            setAudioOutputDeviceInternal(null, true);
+        else {
+            final String newDeviceId = "encoded:" + getEncodingFlags(encodings);
+            if (!newDeviceId.equals(mAudioPlugOutputDevice)) {
+                mAudioPlugOutputDevice = newDeviceId;
+                setAudioOutputDeviceInternal(mAudioPlugOutputDevice, true);
+            }
+        }
+        return true;
+    }
+
     private synchronized boolean setAudioOutputDeviceInternal(String id, boolean fromUser) {
         mAudioOutputDevice = id;
         if (fromUser) {



More information about the Android mailing list