[Android] Refine audio duck policy
Geoffrey Métais
git at videolan.org
Wed Nov 22 16:08:12 CET 2017
vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Nov 17 11:40:10 2017 +0100| [c0585a16abc5325bc49ce308226433b355bd243b] | committer: Geoffrey Métais
Refine audio duck policy
(cherry picked from commit 6395e16bfc01864b0e71a820d77fb5bab64640af)
> https://code.videolan.org/videolan/vlc-android/commit/c0585a16abc5325bc49ce308226433b355bd243b
---
vlc-android/src/org/videolan/vlc/PlaybackService.java | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index bb6a7841a..5b967a45c 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -415,15 +415,20 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
Log.i(TAG, "AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK");
// Lower the volume
if (isPlaying()) {
- if (AndroidDevices.isAndroidTv) {
+ if (AndroidDevices.isAmazon) {
pausePlayback();
} else {
- final int volume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
+ final int volume = AndroidDevices.isAndroidTv ? getVolume()
+ : mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
if (audioDuckLevel == -1)
- audioDuckLevel = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)/5;
+ audioDuckLevel = AndroidDevices.isAndroidTv ? 50
+ : mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)/5;
if (volume > audioDuckLevel) {
mLossTransientVolume = volume;
- mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, audioDuckLevel, 0);
+ if (AndroidDevices.isAndroidTv)
+ setVolume(audioDuckLevel);
+ else
+ mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, audioDuckLevel, 0);
}
}
}
@@ -432,7 +437,10 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
Log.i(TAG, "AUDIOFOCUS_GAIN: ");
// Resume playback
if (mLossTransientVolume != -1) {
- mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mLossTransientVolume, 0);
+ if (AndroidDevices.isAndroidTv)
+ setVolume(mLossTransientVolume);
+ else
+ mAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC, mLossTransientVolume, 0);
mLossTransientVolume = -1;
}
if (mLossTransient) {
More information about the Android
mailing list