Question

I'm trying to create app that stream radio from internet im using MediaPlayer class for that and its working fine.

i want to add recording function to the app and i use MediaRecorder class for that with this seting

recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

but i it catch the microphone sound. i want to record the stream sound only.

what i can do ?

Was it helpful?

Solution

It's not possible to record the audio playback like that.
It is possible to get audio data from your MediaPlayer by using the Visualizer API, but that audio will be of very low quality since it's intended only for visualizing purposes, so I doubt that it will be good enough for your needs.

Another alternative would be to handle the streaming in a sort of proxy/relay server running within your app, which could then take the audio data it gets from the remote server and write it to a file as well as to your MediaPlayer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top