I'm currently trying to record an audio stream which is played in MediaPlayer
.
Actually I found some blog-post, saying it's not possible because of security / copyright reasons, but I couldn't find any official statements from Android/Google docs. Furthermore, there are screen capture apps like Mobizen which can record internal audio (at least Samsung devices seems to work).
So can someone tell, if
AudioRecorder
which is played in MediaPlayer
?I'm not so sure if I'm entering the dark side at the moment?
What I already tried to answer the 2nd question:
MediaRecorder.AudioSource
, but all record the microphoneMediaPlayer
Coming with the new Android 10 API, there finally is an AudioPlaybackCapture
API.
This API gives apps the ability to copy the audio being played by other apps. This feature is the analogue of screen capture, but for audio.
I personally haven't tested it, yet, but here are the required steps to capture audio, based on the dev guide.
Permissions needed to capture audio:
RECORD_AUDIO
permission.MediaProjectionManager.createScreenCaptureIntent()
, and the user must approve it.To capture the audio, you then need to build an AudioRecord
object and add the AudioPlaybackCaptureConfiguration
to it:
AudioPlaybackCaptureConfiguration.Builder.build()
to build an AudioPlaybackCaptureConfiguration
.AudioRecord
by calling setAudioPlaybackCaptureConfig
.You can also constrain the capture by AUDIO_USAGE
or a UID
, see: Constraining capture by audio content
I highly recommend that you check out the Android Dev Guide.
09/01/2020 Update: Android 10.0 now accounts for 29.04% of the Android market share, according to StatCounter.
Mobile & Tablet Android Version Market Share Worldwide, from July 2019 to July 2020. Source: StatCounter
Old answer: Very few devices are running on Android, 10. Google has not released yet the market share, but we can guess that it is at most less than 10%, which is the market share of Android 9.0.
Data collected during a 7-day period ending on May 7, 2019. Any versions with less than 0.1% distribution are not shown. Source: Distribution dashboard