Receive audio via Bluetooth in Android

后端 未结 5 1207
鱼传尺愫
鱼传尺愫 2020-11-30 17:56

I want to create an Android application that is capable of receiving an audio stream. I thought of using the A2DP profile, but is seems as if Android doesn\'t support A2DP s

5条回答
  •  情深已故
    2020-11-30 18:40

    To receive pcm audio stream via rfcomm , you can use code flow as a hint explained (Reading Audio file in C and forwarding over bluetooth to play in Android Audio track) , with a change . change freq used while initializing from 44100 to 22050

    AudioTrack track = new AudioTrack(AudioManager.STREAM_MUSIC,22050,AudioFormat.CHANNEL_OUT_MONO,AudioFormat.ENCODING_PCM_8BIT,10000, AudioTrack.MODE_STREAM);
    

    note:This streaming still consists some noise but your

    "receiving an PCM data stream via the RFCOMM (SPP Bluetooth profile), and then play it using AudioTrack."

    will work.

提交回复
热议问题