Commit 2ae42cb8 authored by Geoffrey Métais's avatar Geoffrey Métais

Restore correct audio volume after notifications

parent 80f2753e
......@@ -352,7 +352,7 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
private OnAudioFocusChangeListener createOnAudioFocusChangeListener() {
return new OnAudioFocusChangeListener() {
private boolean mLossTransient = false;
private boolean mLossTransientCanDuck = false;
private int mLossTransientVolume = -1;
private boolean wasPlaying = false;
@Override
......@@ -380,15 +380,15 @@ public class PlaybackService extends Service implements IVLCVout.Callback {
// Lower the volume
if (mMediaPlayer.isPlaying()) {
mMediaPlayer.setVolume(36);
mLossTransientCanDuck = true;
mLossTransientVolume = mMediaPlayer.getVolume();
}
break;
case AudioManager.AUDIOFOCUS_GAIN:
Log.i(TAG, "AUDIOFOCUS_GAIN: " + mLossTransientCanDuck + ", " + mLossTransient);
Log.i(TAG, "AUDIOFOCUS_GAIN: " + mLossTransientVolume + ", " + mLossTransient);
// Resume playback
if (mLossTransientCanDuck) {
mMediaPlayer.setVolume(100);
mLossTransientCanDuck = false;
if (mLossTransientVolume != -1) {
mMediaPlayer.setVolume(mLossTransientVolume);
mLossTransientVolume = -1;
} else if (mLossTransient) {
if (wasPlaying)
mMediaPlayer.play();
......
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