Mute Entire App

I want to mute everything in my app with the press of a button. I have the button, but what it currently does is only mute the sounds from that screen/file. How is this done? Thanks! [import]uid: 39302 topic_id: 24043 reply_id: 324043[/import]

audio.setVolume( 0 )
[import]uid: 7563 topic_id: 24043 reply_id: 96917[/import]

This will keep it muted as I switch between screens? [import]uid: 39302 topic_id: 24043 reply_id: 96923[/import]

I just store a value in my database. Every time you switch screens you will have to retrieve this value though, and with every sound I have to put an if statement. This method works well for me because the setting will stay even when they close the app or restart it. [import]uid: 31262 topic_id: 24043 reply_id: 96925[/import]

Just so I don’t sound dumb with my next question I want say let you know that I’m new to programming and Corona. :slight_smile: What do you mean database, and how do you retrieve a “value”?
Thanks [import]uid: 39302 topic_id: 24043 reply_id: 96932[/import]

“This will keep it muted as I switch between screens?”

Yes :slight_smile: [import]uid: 52491 topic_id: 24043 reply_id: 97042[/import]

The button I have mutes the app and switches images to show that the app is muted. Now my situation is: After I press the mute button,go to another screen, then come back, it is unmuted and put back to its original “unmuted” image. How do I make it remember that the button was pressed before I left the screen or file? [import]uid: 39302 topic_id: 24043 reply_id: 97342[/import]

Save the value of the button to a file … something like

soundIsMuted = 1 -- sound is muted  
soundIsMuted = 0 -- sound unmuted  
  
--save the above to a file   

Then when you read that value back you can simply display the correct button

  
if soundIsMuted == 1 then  
 --set button to muted frame  
else  
 --set button to un-muted frame  
end  
  

If your new to storing/saving/loading data, check out ICE (it’s available via the code base and makes things like this very easy) [import]uid: 84637 topic_id: 24043 reply_id: 97357[/import]

It it genuinely unmuted or is it just that the icon has gone back to the original?

You have two options for the icon - one is to save whether or not it is muted to a file and check when you return to the menu.

The other is to use a global variable so it “remembers” it across scenes. Globals aren’t recommended but my personal belief is using one in your app is no big deal. (Others may disagree but this is how I tend to do it and have had no issues thus far.) [import]uid: 52491 topic_id: 24043 reply_id: 97362[/import]

Yeah there is nothing wrong with using Globals, best not to get carried away with using too many of them though i guess [import]uid: 84637 topic_id: 24043 reply_id: 97363[/import]

@Peach- It returns to being unmuted.
Would it be worth figuring out ICE just for this? I have heard of it before, but I never messed around with it… [import]uid: 39302 topic_id: 24043 reply_id: 97374[/import]

Maybe not just for this particular problem, but im sure you have other data which will need saving/loading also besides this ? [import]uid: 84637 topic_id: 24043 reply_id: 97375[/import]

Yes, I probably will. My app keeps growing as I get new ideas.

Am I pretty much on my own with figuring out how ICE works? [import]uid: 39302 topic_id: 24043 reply_id: 97378[/import]

Not at all!

I use it personally myself, along with plenty of members here. There is also plenty of examples demonstrated on the ICE codebase page :slight_smile: [import]uid: 84637 topic_id: 24043 reply_id: 97379[/import]

Awesome! I would start working right now, but I can’t. I’m sure I’ll have some more questions in a couple days Thanks! [import]uid: 39302 topic_id: 24043 reply_id: 97385[/import]

You changed your picture, Danny! :slight_smile:

Is there any other help around besides the demo that the ICE doc came with and this–http://developer.anscamobile.com/code/ice?page=4&destination= ? [import]uid: 39302 topic_id: 24043 reply_id: 98559[/import]

Yeah I changed it :slight_smile:

Thats pretty much it, however the developer Graham is always around on the forums here, and is also very prompt at answering emails, and of course you have myself and a lot of other users of Ice here to help [import]uid: 84637 topic_id: 24043 reply_id: 98563[/import]

Okay.

Do I need to put this…

[code]
require( “ice” )

local settings = ice:loadBox( “settings” )[/code]

…in every file that I want to use ICE and the “settings?” [import]uid: 39302 topic_id: 24043 reply_id: 98568[/import]

I usually just put that in my main.lua file, then all files can access it. But like this

local ice = require("ice")  

Then in the other files you can simply do

local settings = ice:loadBox( "settings" )  

Or also put that in your main.lua file, whichever suits [import]uid: 84637 topic_id: 24043 reply_id: 98570[/import]

Alright. I thought “local” made the variable (is that what it is?) confined to that file. I’m assuming I’m wrong… [import]uid: 39302 topic_id: 24043 reply_id: 98572[/import]