4

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 me?

thanks, Ramachandran.R

Ganapathy C
  • 5,989
  • 5
  • 42
  • 75
Jeeva
  • 1,166
  • 4
  • 18
  • 39
  • possible duplicate of [Android: How to record mp3 radio (audio) stream](http://stackoverflow.com/questions/5381969/android-how-to-record-mp3-radio-audio-stream) – MSalters Mar 31 '11 at 13:58

2 Answers2

3

There is no FM radio support in the Android SDK. Various device manufacturers may have hacked in their own FM radio support, but you would have to contact those manufacturers to learn what APIs, if any, they have for them.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
2

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();  
K.Muthu
  • 1,232
  • 1
  • 17
  • 38
  • This code works! It will record what the FM tuner app that comes with some Android devices is currently playing. Thanks! –  Jul 30 '12 at 18:30