@Override public void onAudioFocusChange(int i) { if (musicFocusable == null) { return; } switch (i) { case AudioManager.AUDIOFOCUS_GAIN: Logger.debug(TAG, ">>>" + "onAudioFocusChange AUDIOFOCUS_GAIN"); musicFocusable.onGainedAudioFocus(); break; case AudioManager.AUDIOFOCUS_LOSS: case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT: Logger.debug(TAG, ">>>" + "onAudioFocusChange AUDIOFOCUS_LOSS"); musicFocusable.onLostAudioFocus(false); break; case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK: Logger.debug(TAG, ">>>" + "onAudioFocusChange AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK"); musicFocusable.onLostAudioFocus(true); break; default: } }
/** * Called by AudioManager on audio focus changes. We implement this by calling our MusicFocusable * appropriately to relay the message. */ public void onAudioFocusChange(int focusChange) { if (mFocusable == null) return; switch (focusChange) { case AudioManager.AUDIOFOCUS_GAIN: mFocusable.onGainedAudioFocus(); break; case AudioManager.AUDIOFOCUS_LOSS: case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT: mFocusable.onLostAudioFocus(false); break; case AudioManager.AUDIOFOCUS_LOSS_TRANSIENT_CAN_DUCK: mFocusable.onLostAudioFocus(true); break; default: } }