[Android] Option in video player to play as audio

Geoffrey Métais git at videolan.org
Fri Mar 27 17:37:15 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Mar 27 17:36:49 2015 +0100| [b5f51fd9c165b97f1dab2169290cda231c4790ab] | committer: Geoffrey Métais

Option in video player to play as audio

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

 vlc-android/res/layout/fragment_advanced_options.xml      |   13 +++++++++++++
 .../src/org/videolan/vlc/gui/video/AdvOptionsDialog.java  |   10 +++++++++-
 .../org/videolan/vlc/gui/video/VideoPlayerActivity.java   |    6 +-----
 3 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/vlc-android/res/layout/fragment_advanced_options.xml b/vlc-android/res/layout/fragment_advanced_options.xml
index fb1bf1a..9fc7fad 100644
--- a/vlc-android/res/layout/fragment_advanced_options.xml
+++ b/vlc-android/res/layout/fragment_advanced_options.xml
@@ -9,6 +9,18 @@
 
     <!-- Playback speed -->
 
+    <TextView
+        android:id="@+id/playback_switch_audio"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="20dp"
+        android:layout_marginBottom="5dp"
+        android:nextFocusDown="@+id/playback_speed_reset"
+        android:gravity="left"
+        android:clickable="true"
+        android:focusable="true"
+        android:text="@string/play_as_audio"/>
+
     <LinearLayout
         android:id="@+id/playback_speed"
         android:layout_width="match_parent"
@@ -72,6 +84,7 @@
                     android:layout_height="wrap_content"
                     android:layout_marginLeft="10dp"
                     android:focusable="true"
+                    android:nextFocusUp="@+id/playback_speed_reset"
                     android:indeterminate="false"
                     android:max="200"
                     android:maxHeight="@dimen/seekbar_height"
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java b/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java
index c111e97..2372e78 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/AdvOptionsDialog.java
@@ -39,7 +39,6 @@ import android.widget.Button;
 import android.widget.SeekBar;
 import android.widget.TextView;
 
-import org.videolan.libvlc.LibVLC;
 import org.videolan.vlc.BuildConfig;
 import org.videolan.vlc.R;
 import org.videolan.vlc.VLCApplication;
@@ -68,6 +67,8 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
     public static final int DIALOG_LISTENER = 3;
     public static final int RESET_RETRY = 4;
 
+    private TextView mAudioMode;
+
     private TextView mSpeedTv;
     private SeekBar mSeek;
     private Button mReset;
@@ -107,6 +108,10 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
                              Bundle savedInstanceState) {
         View root = inflater.inflate(R.layout.fragment_advanced_options, container, false);
 
+        mAudioMode = (TextView) root.findViewById(R.id.playback_switch_audio);
+        mAudioMode.setOnClickListener(this);
+        mAudioMode.setOnFocusChangeListener(mFocusListener);
+
         mSeek = (SeekBar) root.findViewById(R.id.playback_speed_seek);
         mSpeedTv = (TextView) root.findViewById(R.id.playback_speed_value);
         mReset = (Button) root.findViewById(R.id.playback_speed_reset);
@@ -311,6 +316,9 @@ public class AdvOptionsDialog extends DialogFragment implements View.OnClickList
                 setSleep(v.getContext(), null);
                 mHandler.sendEmptyMessage(TOGGLE_CANCEL);
                 break;
+            case R.id.playback_switch_audio:
+                ((VideoPlayerActivity)getActivity()).switchToAudioMode();
+                break;
         }
     }
 }
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 9d772ec..bfd673c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -95,7 +95,6 @@ import android.widget.Toast;
 import org.videolan.libvlc.EventHandler;
 import org.videolan.libvlc.IVideoPlayer;
 import org.videolan.libvlc.LibVLC;
-import org.videolan.libvlc.LibVlcException;
 import org.videolan.libvlc.LibVlcUtil;
 import org.videolan.libvlc.Media;
 import org.videolan.vlc.MediaDatabase;
@@ -922,9 +921,6 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
         case KeyEvent.KEYCODE_MENU:
             showAdvancedOptions(mAdvOptions);
             return true;
-//            case KeyEvent.KEYCODE_BUTTON_X:
-//            selectAudioTrack();
-//            return true;
         case KeyEvent.KEYCODE_V:
         case KeyEvent.KEYCODE_MEDIA_AUDIO_TRACK:
         case KeyEvent.KEYCODE_BUTTON_X:
@@ -1530,7 +1526,7 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
         }
     }
 
-    private void switchToAudioMode() {
+    public void switchToAudioMode() {
         if (mHardwareAccelerationError)
             return;
         mSwitchingView = true;



More information about the Android mailing list