Playing sound when mute switch set to silent / More Info plugin

Hi all!

I have two apps that have been on the Apple and Google Play stores for a few years, developed here with Corona / Solar2D. The apps are “ACT Audio Proctor” and “SAT Audio Proctor”.

The entire purpose of the apps is to provide a timer for students to simulate an actual SAT or ACT proctoring of a test. So, the app needs to play audio to provide the proctor’s voice and background noise as desired.

As others have noted, the sound won’t play if the user has the device ringer/silent switch turned to “silent.” In other discussions, people have said that Apple doesn’t allow apps to make sounds when the switch is turned to “silent”, but that’s not true. I have many podcast and music apps on my iPhone that can play sound even when I have the phone switch on “silent”, so it’s certainly possible to do. The point is that the silent switch is supposed to suppress UNWANTED sounds, but any student using this app definitely wants the sound in the same way that someone opening a music app expects to hear sounds even when the ringer switch is set to silent.

I have tried both of the following unsupported API workarounds that I have seen suggested here:

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

Neither of those allow music to be played while the switch is set to silent.

On the assumption that it’s impossible to currently accomplish what I’m trying to do with Solar2D, I purchased and installed Scott_Harrison’s “More Info” plugin, and tried to use the moreInfo.isMuted() listener function to find out whether the phone is muted and display a message telling the user to unmute their phone, but it seems to not be working.

Here’s the code I’m trying to use to do that:

==============
moreInfo.isMuted(function (e)
isMuted = e.muted
print("isMuted: "…tostring(e.muted))
end)

if isMuted then
	myTextItems["buttonNoiseText"].text = "Please unmute your phone to hear the audio."

	local mutedCheckTimer = timer.performWithDelay(5000, function()
		moreInfo.isMuted(function (e)
			isMuted = e.muted
		end)

		if isMuted==false then
			myTextItems["buttonNoiseText"].text = "tap for background noise:"
			timer.cancel(mutedCheckTimer)
		end					
	end, -1)
end

==============

This code would change the “tap for background noise” text to an alert about the phone being muted, but it doesn’t work when deployed to iPhones.

So, my questions:

  1. Is there currently any way in Solar2D to get sound to play even when the iPhone switch is set to silent?

  2. Is my moreInfo code wrong? Is moreInfo still operating correctly with iOS 16? The last message I saw from Scott_Harrison was back in February 2022, when he confirmed it was working correctly at that point.

Thanks so much everyone for the help – these forums have been invaluable to me.

Best,

Bobby Hood

I don’t that is in my demo project(I just built this a few seconds ago)

There is not enough code for me to see the bug

Scott,

Thank you so much.

As is often the case, I kept messing with it after posting my question and I found the error I made.

Everything I posted above actually worked perfectly – I just had another function elsewhere that changed the text back to “tap for background noise:”, so moreInfo was doing exactly what it should and my own code was then erasing the result so I couldn’t see it.

I’ve changed it now to be a function called “checkMuted()” that I call at appropriate times so that that won’t happen.

Your moreInfo plugin is amazing, and I really appreciate it, because this gives me the workaround to at least alert people that they need to flip that switch for my app to work as designed.

Thanks so much for the quick response, Scott!!!

1 Like

I’d still love it if anyone knows of a workaround to get sound to play even when the switch is flipped to “silent.”

This code works for us:

if system.getInfo("platform") == "ios" and audio.supportsSessionProperty == true then
	audio.setSessionProperty(audio.MixMode, audio.MediaPlaybackMixMode)
end

Elvo, thank you SO MUCH! I have tested it and it works. You have solved my problem.

Amazing – the two different suggestions I had seen each had ONE of the two parameters, plus a different parameter. I had tried each of those two suggestions but I hadn’t tried mixing and matching the parameters together.

This is great!

Glad I could help! :+1:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.