How to play audio through Bluetooth speaker even when headset is plugged in?

前端 未结 5 688
夕颜
夕颜 2021-02-06 00:53

I have my phone connected to a Bluetooth speaker and the headphones plugged in. Now I\'d like to play audio through the Bluetooth speaker. When I set the audio stream to A

5条回答
  •  天命终不由人
    2021-02-06 00:55

    Solution

    Suppose you already tested STREAM_RING on your new instance of media player and not directly setting stream type, and it didn't work out, You need a correct profile for your bluetooth device.

    Take a look at this article Read the "Implementing HAL" section, there is alot of source for different profile that you may be able to use.

    There is also an easy solution which is to change your device profile to HEADSET in your getServiceConnected() method, it will turn into a Stay connected device but the output will become mono! As I recall, Which is a shame for speakers, A2DP also may not be supported in some hardwares and still interrupted by wire headsets.

    I suggest to create a new profile and use it, a little bit tricky working with HAL but will worth it,

    Sorry that I can not provide a source code for you at the moment.

提交回复
热议问题