Private Audiomanager.onaudiofocuschangelistener Maudiofocuslistener = new Audiomanager.onaudiofocuschangelistener () {
public void Onaudiofocuschange (int focuschange) {
Switch (focuschange) {
Case Audiomanager.audiofocus_gain://Before Volume 1
if (Maudiomanager! = null)
Maudiomanager.setstreamvolume (Audiomanager.stream_music,
(int) (Mmaxvolum * 0.8), 0);
if (Mislossautiofocus) {
Wedriveresume ();
Mislossautiofocus = false;
}
Break
Case Audiomanager.audiofocus_loss_transient_can_duck://down tone processing-3
if (Maudiomanager! = null)
Maudiomanager.setstreamvolume (Audiomanager.stream_music,
(int) (Mmaxvolum * 0.3), 0);
Break
Case Audiomanager.audiofocus_loss_transient://Lost audio focus pause playback-2
Mislossautiofocus = true;
Wedrivepause ();
Break
Case Audiomanager.audiofocus_loss://-1
Wedrivepause ();
Break
Default
Break
}
}
};
Request Focus
Maudiomanager = (Audiomanager) getsystemservice (Context.audio_service);
if (Maudiomanager! = null)
Maudiomanager.requestaudiofocus (Maudiofocuslistener,audiomanager.stream_music,audiomanager.audiofocus_gain);
Discard Focus
if (Maudiomanager! = null)
Maudiomanager.abandonaudiofocus (Maudiofocuslistener);
On-board system Noise Reduction processing