简体   繁体   English

Android:检测当前音频通道

[英]Android: Detect current audio channel

I'm looking to detect how the audio is currently being outputted in my android phone. 我正在寻找在我的Android手机中检测音频当前是如何输出的。

I've been testing with: 我一直在测试:

android.bluetooth.headset.profile.action.AUDIO_STATE_CHANGED

Which offers information when the current audio device is a bluetooth head phone and when it is not, which is part of the solution. 当当前的音频设备是蓝牙耳机时,它提供的信息,当它不是时,它提供信息,这是解决方案的一部分。

However, I cannot seem to capture when the audio is being routed to the speakers versus the receiver versus wired headphones. 然而,当音频被路由到扬声器而不是接收器与有线耳机时,我似乎无法捕获。

Ideally, there would be one broadcast which I am listening to, that fires whenever the audio route changes, such as when toggling between them during a call. 理想情况下,我会收听一个广播,每当音频路径发生变化时就会触发,例如在通话期间切换它们时。

There is AUDIO_BECOMING_NOISY intent which fires when the sound is being switched from headphones to speakers (see http://developer.android.com/guide/topics/media/mediaplayer.html#noisyintent ). 有声音从耳机切换到扬声器时会触发AUDIO_BECOMING_NOISY意图(请参阅http://developer.android.com/guide/topics/media/mediaplayer.html#noisyintent )。

And there is also a way for detecting the opposite switch, see How to detect when a user plugs headset on android device? 并且还有一种检测相反开关的方法,请参阅如何检测用户何时在Android设备上插入耳机? (Opposite of ACTION_AUDIO_BECOMING_NOISY) (与ACTION_AUDIO_BECOMING_NOISY相反)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM