Skip to main content
February 20, 2013
Question

Android: Volume media/ringer mode reseting on minimise

  • February 20, 2013
  • 2 replies
  • 2225 views

This is an existing bug that was recently noticed by a user. On android devices normally the volume buttons change the ringer volume. When a sound is played in air, it switches to a separate media volume setting as expected, and appears to stay this way for a few seconds afterward before switching back to ringer. The problem is when a user presses the home key to minimise the app before the cooldown period elapses to do something else, the volume gets stuck on media and stays that way, unless the user goes back to the app and the time elapses.

This is an issue for me since my app plays background music all the time, so the cooldown time never elapses and thus this bug always occurs on minimise. My guess is it has something to do with background music being enabled. Is there a way to disable background music?

This topic has been closed for replies.

2 replies

Adobe Employee
August 29, 2013

Hi AdaptedArts,

You can use Event.DEACTIVATE event to stop the background music. Event.DEACTIVATE is called when the application loses focus e.g. phone call, press home button.

for example, if you have music playing in a sound channel then you can use the below code to stop music:

NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, deactivateMusic);

function deactivateMusic(event:Event):void {

      // application is now losing focus

      musicChannel.stop();    // stops the music, "musicChannel is a SoundChannel"

}

Also, if you want to start the music again, then use Event.ACTIVATE event.

NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, activateMusic);

function activateMusic(event:Event):void {

      musicChannel = mySong.play();   

}

Hope this will helps.

Regards,

Nimit

September 2, 2013

I don't think you quite understood the issue, nimitja... It's not that the music doesn't stop, but rather that when using the device's volume control buttons (the physical ones) the device adjusts the media volume even when the app is minimized (and thus not playing music anymore) instead of adjusting the ringer volume.

For the record, I'm already doing what you suggested to stop all sounds upon minimizing

Adobe Employee
September 19, 2013

okay, that means when application is in background and sound is stopped, even then the volume control buttons are able to adjusts the sound volume. Please correct me if I am wrong.

I will recheck it again and let you know.

Regards,

Nimit

August 28, 2013

Did you ever find a way to fix this?