Last active
June 17, 2016 06:56
-
-
Save atlantis0/10d085eecf06ca86b51db0caa6db3a75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onAudioFocusChange(int focusChange) { | |
switch (focusChange) { | |
case AudioManager.AUDIOFOCUS_GAIN: | |
// resume playback, | |
// it is now safe to continue playing | |
break; | |
case AudioManager.AUDIOFOCUS_LOSS: | |
// Lost focus for an unbounded amount of time: stop playback and release media player | |
break; | |
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT: | |
// Lost focus for a short time, but we have to stop | |
// playback. We don't release the media player because playback | |
// is likely to resume | |
break; | |
case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK: | |
// Lost focus for a short time, but it's ok to keep playing | |
// at an attenuated level | |
// Todo - lower volume | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment