[Android] Hide Passthrough option if device cannot do it

Geoffrey Métais git at videolan.org
Fri Apr 20 09:11:01 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Apr 19 18:05:47 2018 +0200| [b5a1944ca704661534c3d61874f80b09b5454c88] | committer: Geoffrey Métais

Hide Passthrough option if device cannot do it

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

 .../src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java  | 13 ++++++++-----
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java |  1 +
 vlc-android/src/org/videolan/vlc/media/PlayerController.kt  |  2 ++
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
index b5b4a5479..0c1512d6d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/dialogs/AdvOptionsDialog.java
@@ -72,6 +72,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
     public final static String TAG = "VLC/AdvOptionsDialog";
     public static final String MODE_KEY = "mode";
     public static final String PRIMARY_DISPLAY = "primary_display";
+    public static final String PASSTHROUGH = "passthrough";
     public static final int MODE_VIDEO = 0;
     public static final int MODE_AUDIO = 1;
 
@@ -97,7 +98,8 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
 
     private Activity mActivity;
     private int mMode = -1;
-    private boolean primary;
+    private boolean mPrimary;
+    private boolean mPassthrough;
 
     AutoFitRecyclerView mRecyclerView;
     private AdvOptionsAdapter mAdapter;
@@ -133,7 +135,8 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
         final Bundle args = getArguments();
         if (args != null) {
             mMode = args.containsKey(MODE_KEY) ? args.getInt(MODE_KEY) : MODE_VIDEO;
-            primary = args.containsKey(PRIMARY_DISPLAY) && args.getBoolean(PRIMARY_DISPLAY);
+            mPrimary = args.containsKey(PRIMARY_DISPLAY) && args.getBoolean(PRIMARY_DISPLAY);
+            mPassthrough = args.getBoolean(PASSTHROUGH);
         }
         setStyle(DialogFragment.STYLE_NO_FRAME, 0);
         mHelper = new PlaybackServiceActivity.Helper(getActivity(), this);
@@ -552,11 +555,11 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
         mAdapter.addOption(new Option(ID_EQUALIZER, R.attr.ic_equalizer_normal_style, getString(R.string.equalizer)));
 
         if (mMode == MODE_VIDEO) {
-            if (primary && !tvUi && mService.getAudioTracksCount() > 0)
+            if (mPrimary && !tvUi && mService.getAudioTracksCount() > 0)
                 mAdapter.addOption(new Option(ID_PLAY_AS_AUDIO, R.attr.ic_playasaudio_on, getString(R.string.play_as_audio)));
             mAdapter.addOption(new Option(ID_SPU_DELAY, R.attr.ic_subtitledelay, getString(R.string.spu_delay)));
             mAdapter.addOption(new Option(ID_AUDIO_DELAY, R.attr.ic_audiodelay, getString(R.string.audio_delay)));
-            if (primary && (!tvUi || AndroidDevices.hasPiP) && !AndroidDevices.isDex(getActivity()))
+            if (mPrimary && (!tvUi || AndroidDevices.hasPiP) && !AndroidDevices.isDex(getActivity()))
                 mAdapter.addOption(new Option(ID_POPUP_VIDEO, R.attr.ic_popup_dim, getString(R.string.popup_playback_title)));
             mAdapter.addOption(new Option(ID_REPEAT, R.attr.ic_repeat, getString(R.string.repeat_title)));
             if (mService.canShuffle())
@@ -571,7 +574,7 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
         } else {
             mAdapter.addOption(new Option(ID_SAVE_PLAYLIST, R.attr.ic_save, getString(R.string.playlist_save)));
         }
-        if ("0".equals(prefs.getString("aout", "0")))
+        if (mPassthrough && "0".equals(prefs.getString("aout", "0")))
             mAdapter.addOption(new Option(ID_PASSTHROUGH, R.attr.ic_passthrough, getString(R.string.audio_digital_title)));
         setDialogDimensions(large_items);
     }
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index d5ad28698..9a07dc2e9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -3105,6 +3105,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         final AdvOptionsDialog advOptionsDialog = new AdvOptionsDialog();
         final Bundle args = new Bundle(1);
         args.putBoolean(AdvOptionsDialog.PRIMARY_DISPLAY, mDisplayManager.isPrimary());
+        args.putBoolean(AdvOptionsDialog.PASSTHROUGH, mService.getPlaylistManager().getPlayer().canDoPassthrough());
         advOptionsDialog.setArguments(args);
         advOptionsDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
             @Override
diff --git a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
index 70ef05221..b67fac449 100644
--- a/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
+++ b/vlc-android/src/org/videolan/vlc/media/PlayerController.kt
@@ -38,6 +38,8 @@ class PlayerController : IVLCVout.Callback, MediaPlayer.EventListener {
 
     fun getVout(): IVLCVout? = mediaplayer.vlcVout
 
+    fun canDoPassthrough() = mediaplayer.canDoPassthrough()
+
     fun getMedia(): Media? = mediaplayer.media
 
     fun play() {



More information about the Android mailing list