[Android] Show volume system dialog if setVolume fails

Geoffrey Métais git at videolan.org
Fri Sep 8 15:09:33 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Sep  8 14:46:26 2017 +0200| [6a2f3f81a35a5b2ebe7ca8336237a210b03c5356] | committer: Geoffrey Métais

Show volume system dialog if setVolume fails

System can block it to show high volume warning alert dialog

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

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

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 a32c3721b..d0b85cccd 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -2312,9 +2312,12 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
          * We don't want to always show the default UI volume, so show it only when volume is not set. */
         if (vol <= mAudioMax) {
             mService.setVolume(100);
-            int newVol = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
-            if (vol != newVol)
+            if (vol !=  mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC)) {
                 mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, vol, 0);
+                // High Volume warning can block volume setting
+                if (mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC) != vol)
+                    mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, vol, AudioManager.FLAG_SHOW_UI);
+            }
             vol = Math.round(vol * 100 / mAudioMax);
         } else {
             vol = Math.round(vol * 100 / mAudioMax);



More information about the Android mailing list