navigation - Pausing Android MediaPlayer for Synthesized Speech -
i have android mediaplayer running want pause when speech synthesizer starts speaking (specifically, when google navigation app gives directions). i'm pretty sure possible, standard music player seems have behavior.
i've learned (from stack overflow gods) how pause mediaplayer during phone calls:
pause music player on phone call , again resume after phone call in android
i'm surprised haven't been able find similar mechanism listen events speech synth. assume i've missed something, , if can point me @ link or hint @ answer here, i'd grateful.
i have found answer this:
http://developer.android.com/reference/android/media/audiomanager.onaudiofocuschangelistener.html
the navigation app calls audio focus using "notifications" stream. requested audio focus stream (and music stream well) in application. pause/restart player in callback method audio focus changes , you're go.
note: won't work all synthesized speech. i've tried using test button in speech synthesis settings menu , doesn't fire callback. works if "competing" applications nice enough have requested audio focus appropriate stream.
Comments
Post a Comment