3

May I know what is the reason why Android phone's music player will stop playing music when I switch to camera mode?

I find it logical if the music player stop playing music when taking a movie but stopping playing music when taking photo seems to be quite illogical since the photo taken will not save any sound.

1

This is an old question, but I think that some people might find it useful since I came it across using Google search.

The camera app has a permission called TAKE_AUDIO_FOCUS which it is granted by default to it. The camera app uses this to pause the music while you open the viewfinder on your phone.

To fix this issue, you can simply disable the TAKE_AUDIO_FOCUS permission from your phone. The problem here is that you can't do it via the UI since the toggle for it isn't there.

The simplest way to not allow the camera app on your phone to pause your music is to take off this permission using the adb shell.

  1. Download your OEM USB drivers from your phone's manufacturer's website. A simple Google search should give you the link.
  2. Download Minimal ADB portable and extract it to a folder on your desktop.
  3. Connect your phone to your PC and enable USB Debugging. For that, Go to Settings > About Phone > Tap on the Build Number 7 times. This will unlock the Developer options on your phone. Now, Go to the Developer mode from Settings. Enable USB Debugging.
  4. Now, open the folder where you extracted the Minimal ADB and Shift + Right-click on an empty space. From the context menu, select Open Command Window Here.
  5. In the command window type adb devices.
  6. Press OK on your Android phone when it asks you to give the permission for USB Debugging.
  7. Now, type adb shell to open the command line interpreter on Android.
  8. Type the following command to remove the TAKE_AUDIO_FOCUS permission from your Camera app:

    appops set app.package.name TAKE_AUDIO_FOCUS ignore

You will need to replace the app.package.name with the app's package name of the camera app in your Android phone. Since most manufacturers don't follow a single standard for naming their camera apps, you'll need to use a package info app from the Play Store to know the package name. Use App inspector for this.

Suppose your phone is a Moto G. You can type the following command to remove the TAKE_AUDIO_FOCUS permission

appops set com.motorola.cameraone TAKE_AUDIO_FOCUS ignore

That should be it.

Source: my own article here.

0

You can also try installing a different camera app that does not take audio focus. I tried the "Camera MX" app for instance, and it does not appear to pause audio playback.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.