Android Question Set audio path to BT device(Solved)

Nizze

Active Member
Licensed User
Longtime User
Hi

After searching the forum wihtout finding my ansver .

How can i set sound ??
I want to play sound in BT device and not in my phone .

But i cant find info on how to do that

i recive a audio stream like this :
Code:
audioStream.Initialize("AudioStream", 8000, True, 16, audioStream.VOLUME_MUSIC)

Then it will "play" in the phones speaker.
How do i get it in my paired BT device ?

Br
Nizze
 
The audio routing should be handled automatically by the OS.

Does it play the music through the Bluetooth device is you play it with MediaPlayer (play a different file)?
Hi Erel
The BT device works only with audio when i use Phone , not with any Media Player .
The device is a SAVOX BTR-155 . It is a BT mic/speaker with PTT function

I found the ptt function, and it works .
Code:
Sub Serial1_Connected (Success As Boolean)
   
    If Success Then
        ToastMessageShow("Ptt Button connected ", False)
        TestStream.Initialize(Serial1.InputStream,Serial1.OutputStream,"TestStream")
    End If
   
End Sub

Sub teststream_NewData (Buffer() As Byte)
    Dim msg As String
    msg = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
   
    Select Case msg
       
        Case "+PTT=P" 'Ptt button pressed
            PTT_ON
        Case "+PTT=R" 'Ptt button relesed
            PTT_OFF   
       
    End Select
   
    'ToastMessageShow(msg, False)
End Sub

So i need to turn on this audio path like phone does
Is there anything in Phone i can use ?


// Nizze
 
Last edited:
Upvote 0
Done some mor tests ..
But no Luck so far

Code:
Sub StartBluetoothSco()
  Dim r As Reflector
  ToastMessageShow("Start sco", False)

  r.Target = r.GetContext
  r.Target = r.RunMethod2("getSystemService", "audio", "java.lang.String")
  r.RunMethod("startBluetoothSco")
  Log("StartBluetoothSco") '<--------------
End Sub

And in Manifest added:

Code:
AddPermission(android.permission.BLUETOOTH)
AddPermission(android.permission.BLUETOOTH_ADMIN)
AddPermission(android.permission.MODIFY_AUDIO_SETTINGS)

Update this code .

It works !
 
Last edited:
Upvote 0
Thanks Nizze :) Just spent the whole day yesterday around several codes but this one only worked for me:

Sub StartBluetoothSco()
Dim r As Reflector
ToastMessageShow("Start sco", False)

r.Target = r.GetContext
r.Target = r.RunMethod2("getSystemService", "audio", "java.lang.String")
r.RunMethod("startBluetoothSco")
Log("StartBluetoothSco") '<--------------
End Sub



except that I had to add these:
(Service_Create)
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_ALWAYS


(Activity_Resume)
r.RunMethod("startBluetoothSco")


as the control of the bluetooth key (from the headset) gets overridden by Google Now after the first click (meaning I used the headset's physical button to trigger transfer of audio to the headset).
 
Upvote 0
Back
Top