Reputation: 3332
I am developing an app to control a speaker. I want the app to be able to playback music, do karaoke (play music and mic at same time), and provide a basic EQ to the user. My problem so far has been playing music through Bluetooth at all. My app: -discovers all Bluetooth speakers nearby -puts them in a list -pairs with clicked device and sends user to Bluetooth settings to connect to it Now my problem is successfully playing music over the bluetooth speakers. I use a AudioManager and set it to play over SCO:
audioManager.setMode(AudioManager.MODE_IN_CALL);
audioManager.startBluetoothSco();
audioManager.setBluetoothScoOn(true);
And then try to play a music file, but this only plays over the devices speakers and not the connected Bluetooth speakers. So my question is what am i missing? I read a bit about a A2DP sink but it seems to not be available in recent versions. Any suggestions? Thanks in advance. TDLR: How do I playback music to paired Bluetooth speakers?
Upvotes: 0
Views: 1686
Reputation: 672
http://developer.android.com/reference/android/media/AudioManager.html#startBluetoothSco%28%29
it's a sticky intent to so you can always check the status before calling the setBluetoothScoOn(true).
Upvotes: 0
Reputation: 11
The startBluetoothSco()
method returns before SCO is setup. You need to register a BroadcastReceiver
for ACTION_SCO_AUDIO_STATE_UPDATED
before calling the above method.
Upvotes: 1