android get device overall audio output in pcm

2019-01-11 11:09发布

问题:

Is there any way to intercept or just-read the audio output in android device?

I need to read the whole audio output in PCM from inside myActivity, including media player application in background, voice from calls, MediaPlayer istances inside myACtivity, etc., everything that's going to played by speakers. Actually, if it was possible to read them separately, would be great as well.

I tried with AudioRecord, giving it as audioSource parameter every constant found in MediaRecorder.AudioSource with no luck, should I try different audioSources?

Is it a so low-level task that has to be handled within native layer?

回答1:

The visualizer class is helpful. I use it to playback immediately played audio here.

This audio comes in very low quality, however, so it's only really good for visualization.