Commit 515d38b6 authored by Geoffrey Métais's avatar Geoffrey Métais

Catch SecurityException on volume change

Some device may throw a SecurityException when we ask for volume change.
Maybe related to 'Do not Disturb' mode.
parent 51a9d0f7
......@@ -2290,10 +2290,12 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
if (vol <= mAudioMax) {
mService.setVolume(100);
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);
try {
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);
} catch (SecurityException ignored) {} //Some device won't allow us to change volume
}
vol = Math.round(vol * 100 / mAudioMax);
} else {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment