How to record an FM audio in android?

后端 未结 2 1166
孤街浪徒
孤街浪徒 2021-01-01 04:55

i need to record the songs being played by a FM app. I checked the MediaRecorder.AudioSource but could not find what to use for setAudioSource

can anyone please help

2条回答
  •  清酒与你
    2021-01-01 05:26

    try this code

        int audioSource = MediaRecorder.AudioSource.VOICE_DOWNLINK;  
        int sampleRateInHz = 8000;  
        int channelConfig = AudioFormat.CHANNEL_CONFIGURATION_MONO;  
        int audioFormat = AudioFormat.ENCODING_PCM_16BIT;  
        bufferSize = AudioRecord.getMinBufferSize(sampleRateInHz,  
                channelConfig, audioFormat);  
        AudioRecord recordInstance = new AudioRecord(audioSource,  
                sampleRateInHz, channelConfig, audioFormat, bufferSize);  
        recordInstance.startRecording();  
    

提交回复
热议问题