A Fuse Powered Company

Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Allowing background music and the mute button on iOS
Started by jonjonsson Mar 05 2014 08:24 PM

15 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,045 posts
  • Enterprise

I have background music enabled in my app as described here.

 

The problem is if a player has muted the iOS device with the mute button you can still here the game sounds. This is not the behavior I notice from other apps. Other apps that allow background music will mute the game sfx when the device is muted.

 

Any workaround for this? 



[TOPIC: post.html]
#2

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,045 posts
  • Enterprise

Gonna try a bump! It is quite annoying when my game starts blasting sounds while muted :) Do others have this problem when allowing background music?



[TOPIC: post.html]
#3

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 12,248 posts
  • Corona Staff

I don't know if this is the expected behavior or not.  I would go ahead and file a bug report.  Engineering is going to want a project.

 

Rob



[TOPIC: post.html]
#4

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,648 posts
  • Enterprise

The issue is that the mute button on iOS devices mutes the Ringer, not the Volume.



[TOPIC: post.html]
#5

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,648 posts
  • Enterprise

If you start the Music app on iOS and play a song you'll still hear music being played even though the device is "muted" as the mute button is only muting the Ringer...



[TOPIC: post.html]
#6

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,045 posts
  • Enterprise

The issue is that the mute button on iOS devices mutes the Ringer, not the Volume.

 

I just tried at least 10 apps and as soon as you hit the mute button the volume is muted. This is the case for Corona apps as well if they don't have background music enabled.

 

The music app should play even if muted as you said. Games that allow background music always only mute the SFX which I think is the standard way.

 

I guess I will report this then.



[TOPIC: post.html]
#7

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,045 posts
  • Enterprise

OK I found a couple of apps that allow background music and are not muting on mute. I guess this is all over the place.



[TOPIC: post.html]
#8

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,648 posts
  • Enterprise

I guess it's a matter of how the core audio functions are implemented. It might be possible for CoronaLabs to figure out a way to mute the audio even though UIBackgroundModes={"audio"} is active.

 

If you remove UIBackgroundModes = {"audio"} from your build.settings, then the audio will not play while muted. However it will stop any music playing when you start the app.



[TOPIC: post.html]
#9

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,045 posts
  • Enterprise

Yeah or maybe the native way might also  be to detect when device is muted and just not play the sounds then. Don't think we have that option. addEventListener is not picking up anything when I press the mute button at least.



[TOPIC: post.html]
#10

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,648 posts
  • Enterprise

This (rather old) thread seems to address the issue natively. Haven't tried it though...

http://stackoverflow.com/questions/287543/how-to-programmatically-sense-the-iphone-mute-switch



[TOPIC: post.html]
#11

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,045 posts
  • Enterprise

Thanks for the help. I'm going to dump this issue onto my low priority pile for now. Maybe I'll make a feature request.



[TOPIC: post.html]
#12

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,045 posts
  • Enterprise

Problem is solved it looks like!

 

An anonymous hero posted here: http://feedback.coronalabs.com/forums/188732-corona-sdk-feature-requests-feedback/suggestions/5416670-allow-external-music-audio-to-keep-playing-in-back

 

And he is using

audio.setSessionProperty(audio.MixMode, audio.AmbientMixMode)

 

instead of :

audio.setSessionProperty(audio.OverrideMixWithOthers, audio.MediaPlaybackMixMode)

 

And so far in my tests it is working perfectly, very happy with this. 



[TOPIC: post.html]
#13

ingemar

[GLOBAL: userInfoPane.html]
ingemar
  • Corona Geek

  • 2,648 posts
  • Enterprise

Former CoronaLabs audio engineer Eric Wing (ewing) talked about these settings here:

http://forums.coronalabs.com/topic/8742-new-audiosession-properties/



[TOPIC: post.html]
#14

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,045 posts
  • Enterprise

Ok that is good thread. I just noticed in my code I used to have that "new" method but eventually commented it out and put that non working instead  :wacko:



[TOPIC: post.html]
#15

Lerg

[GLOBAL: userInfoPane.html]
Lerg
  • Contributor

  • 106 posts
  • Enterprise

[TOPIC: post.html]
#16

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,045 posts
  • Enterprise

I always read your tips Lerg, thanks for those, great stuff.




[topic_controls]
[/topic_controls]