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

Thomas Guillem thomas at gllm.fr
Wed Feb 18 16:27:45 CET 2015


---
 .../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);
     }
-- 
2.1.3



More information about the Android mailing list