[Android] Fix safe volume dialog not displayed when increasing audio volume

Thomas Guillem git at videolan.org
Wed Feb 18 17:35:22 CET 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Feb 18 16:25:57 2015 +0100| [b22311cab8639cbb3580d259e90ef59d3584e4a8] | committer: Thomas Guillem

Fix safe volume dialog not displayed when increasing audio volume

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

 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java     |    7 +++++++
 1 file changed, 7 insertions(+)

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 6efdd8e..6eb0b79 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1623,6 +1623,13 @@ public class VideoPlayerActivity extends ActionBarActivity implements IVideoPlay
 
     private void setAudioVolume(int vol) {
         mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, vol, 0);
+
+        /* Since android 4.3, the safe volume warning dialog is displayed only with the FLAG_SHOW_UI flag.
+         * We don't want to always show the default UI volume, so show it only when volume is not set. */
+        int newVol = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
+        if (vol != newVol)
+            mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, vol, AudioManager.FLAG_SHOW_UI);
+
         mTouchAction = TOUCH_VOLUME;
         showInfo(getString(R.string.volume) + '\u00A0' + Integer.toString(vol),1000);
     }



More information about the Android mailing list