Android record camera and music from players

Viewed 158

I am trying to do following functionality in my mobile app:

  • 1) In my app I have record button. When pressed it starts camera recording

  • 2) if I have music playing in my mobile phone in any of players - this music should overlay the video

  • 3) External microphone in this situation should also record additional sound

So as a result we will have video record+music+microphone sound

Right now, I got stuck while trying to get access to android.permission.CAPTURE_AUDIO_OUTPUT (I am not using root access btw and can't use it)

Is there a way to solve 1+2+3(record+music+microphone) ? If yes, how can one solve it?

1 Answers

Not really an answer, but too long for a comment.

Guess you should take a look at MediaRecorder here and the android.permission.RECORD_AUDIO permission. But MediaRecorder is only working with MediaPlayer. So if you are using Exoplayer or similar it's not a solution. Be aware, that this might not work on all hardware devices and with all Android Versions (I think you should test with Android 10 first)!

Be aware of AudioFocusManager on Android. If you start the camera, it will request the AudioFocus, so other music apps on your device will stop playing music if you request the camera with sound. (There are differences between Android 10 and below).

Furthermore, camera is using device microphone, so I think recording microphone and camera input at the same time might not work, but you can always use the video-sound in this case.

Related