question

yuanwong-7078 avatar image
0 Votes"
yuanwong-7078 asked ·

How to make the Bluetooth speakers output sound faster after connected by programming?

I have tried three ways to connect Bluetooth on WPF.

 using Windows.Devices.Bluetooth;
 async void ConnectBTUWP()
 {
   btdevice = await BluetoothDevice.FromIdAsync(BTId);
   rfcommResult = await btdevice.GetRfcommServicesAsync();
   rfcomm = rfcommResult.Services[1];
    
     if (btdevice.ConnectionStatus != BluetoothConnectionStatus.Connected)
       {
         // Create a socket and connect to the target
         var _socket = new StreamSocket();
         await _socket.ConnectAsync(
         rfcomm.ConnectionHostName,
         rfcomm.ConnectionServiceName,
         SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication);
       }
    
 }

 using InTheHand.Net;
 using InTheHand.Net.Sockets;
 using InTheHand.Net.Bluetooth;
 using System.Net.Sockets;
    
 public void ConnectBT(string MACAddr)
 {
   var device = new BluetoothDeviceInfo(BluetoothAddress.Parse(MACAddr));
   var remoteEP = new BluetoothEndPoint(device.DeviceAddress, BluetoothService.GenericAudio);
   var socket = new Socket((AddressFamily)32, SocketType.Stream, ProtocolType.Ggp);
   try
   {
      if (device != null)
      {
         socket.BeginConnect(remoteEP, null, null);
      }
   }
   catch (Exception x)
   {
      Console.WriteLine("!ERROR! " + x);
   }
 }

 using InTheHand.Net;
 using InTheHand.Net.Sockets;
 using InTheHand.Net.Bluetooth;
    
 public void ConnectBT(string MACAddr)
 {
   bl = new BluetoothClient();
   var device = new BluetoothDeviceInfo(BluetoothAddress.Parse(MACAddr));
   var remoteEP = new BluetoothEndPoint(device.DeviceAddress, BluetoothService.GenericAudio);
      
   try
   {
      if (device != null)
      {
       device.SetServiceState(BluetoothService.AudioSink, true);
       device.SetServiceState(BluetoothService.AVRemoteControl, true);
       device.SetServiceState(BluetoothService.Handsfree, true);
       device.SetServiceState(BluetoothService.GenericAudio, true);
       bl.BeginConnect(device.DeviceAddress, BluetoothService.GenericAudio, new AsyncCallback(BluetoothConnectedAsyncHandler), device);
      }
   }
   catch (Exception x)
   {
      Console.WriteLine("!ERROR! " + x);
   }
 }


These are immediately connected to the Bluetooth speaker, ↓

8854-%E6%9C%AA%E5%91%BD%E5%90%8D.png


but no sound until "music" shown up. ↓ It takes 5 seconds.

8834-%E6%9C%AA%E5%91%BD%E5%90%8D.png






This problem can't see when I click the "connect" button,↓

8863-5.jpg

Bluetooth speaker connects as "Connected Voice, music" immediately.↓

8871-6.png


How to play sound faster like normal connect way when bt device connected by programming?
Thanks!


not-supported
未命名.png (2.7 KiB)
未命名.png (3.0 KiB)
5.jpg (12.4 KiB)
6.png (43.4 KiB)
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers