问题
I want to create Android application, which will record all audio from the device speakers. For example somebody is watching youtube video on the phone and he will be able to save sound from it, using my application.
Is it possible without framework modification ?
回答1:
There's the Visualizer class that let's you grab a low-quality version of the currently playing audio. It probably wouldn't be good enough for the use-case you describe though.
Other than that there's no officially supported way of recording audio output in Android. You could of course turn up the speaker volume and try to record the speaker output with the phone's microphone, but that will most likely sound as bad or worse as the audio you can get through the Visualizer
.
There are platforms that provide support at the hardware and driver level for accessing audio output (after mixing and volume/effect application) as a recording device by looping the audio back into an ALSA PCM capture device. But I'm not aware of any Android phones that implement this in a way that can be used by app developers.
来源:https://stackoverflow.com/questions/15003241/get-android-audio-stream