Receive audio via Bluetooth in Android

后端 未结 5 1212
鱼传尺愫
鱼传尺愫 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:39

    Another work around is using HandsFreeProfile.

    in Android, BluetoothHeadset is working on that. Wait until status changed to BluetoothHeadset.STATE_AUDIO_CONNECTED.

    then you can record audio from bluetooth headset.

        mMediaRecorder = new MediaRecorder();
        mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
        mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        mMediaRecorder.setOutputFile(mFilename);
        mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        try {
            mMediaRecorder.prepare();
        } catch (IllegalStateException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        mMediaRecorder.start();
    

提交回复
热议问题