开发者

Android: Getting Notified when Audio is Played

开发者 https://www.devze.com 2023-01-24 11:39 出处:网络
Is it possible to be notified in Android when the Audio system starts playing audio? it looks like 开发者_开发知识库i should wire up a BroadcastReceiver, but it\'s not clear what i would listen for. I

Is it possible to be notified in Android when the Audio system starts playing audio? it looks like 开发者_开发知识库i should wire up a BroadcastReceiver, but it's not clear what i would listen for. I could listen for the MediaPlayer intent, but that would only capture when that particular application was playing audio, not when a third party application played audio, etc.

Any ideas?


Looks like it's only available on android OS 2.2+ (froyo) via the AudioManager.OnAudioFocusChangeListener.


Can you hook into this listener events, for pre 2.2

requestAudioFocus() and abandonAudioFocus()

0

精彩评论

暂无评论...
验证码 换一张
取 消