Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Mute Entire App
Started by Nathan B Mar 28 2012 03:21 AM

- - - - -
35 replies to this topic
[TOPIC CONTROLS]
Page 1 of 2 1 2
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Nathan B

[GLOBAL: userInfoPane.html]
Nathan B
  • Contributor

  • 173 posts
  • Corona SDK

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!
uid: 39302 topic_id: 24043 reply_id: 324043


[TOPIC: post.html]
#2

ewing

[GLOBAL: userInfoPane.html]
ewing
  • Corona Geek

  • 1,138 posts
  • Alumni

audio.setVolume( 0 )
uid: 7563 topic_id: 24043 reply_id: 96917


[TOPIC: post.html]
#3

Nathan B

[GLOBAL: userInfoPane.html]
Nathan B
  • Contributor

  • 173 posts
  • Corona SDK

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


[TOPIC: post.html]
#4

aaaron

[GLOBAL: userInfoPane.html]
aaaron
  • Contributor

  • 530 posts
  • Corona SDK

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.
uid: 31262 topic_id: 24043 reply_id: 96925


[TOPIC: post.html]
#5

Nathan B

[GLOBAL: userInfoPane.html]
Nathan B
  • Contributor

  • 173 posts
  • Corona SDK

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. :) What do you mean database, and how do you retrieve a "value"?
Thanks
uid: 39302 topic_id: 24043 reply_id: 96932


[TOPIC: post.html]
#6

peach pellen

[GLOBAL: userInfoPane.html]
peach pellen
  • Corona Geek

  • 8,866 posts
  • Alumni

"This will keep it muted as I switch between screens?"

Yes :)
uid: 52491 topic_id: 24043 reply_id: 97042


[TOPIC: post.html]
#7

Nathan B

[GLOBAL: userInfoPane.html]
Nathan B
  • Contributor

  • 173 posts
  • Corona SDK

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?
uid: 39302 topic_id: 24043 reply_id: 97342


[TOPIC: post.html]
#8

Danny

[GLOBAL: userInfoPane.html]
Danny
  • Corona Geek

  • 2,597 posts
  • Corona Staff

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)
uid: 84637 topic_id: 24043 reply_id: 97357


[TOPIC: post.html]
#9

peach pellen

[GLOBAL: userInfoPane.html]
peach pellen
  • Corona Geek

  • 8,866 posts
  • Alumni

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.)
uid: 52491 topic_id: 24043 reply_id: 97362


[TOPIC: post.html]
#10

Danny

[GLOBAL: userInfoPane.html]
Danny
  • Corona Geek

  • 2,597 posts
  • Corona Staff

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


[TOPIC: post.html]
#11

Nathan B

[GLOBAL: userInfoPane.html]
Nathan B
  • Contributor

  • 173 posts
  • Corona SDK

@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...
uid: 39302 topic_id: 24043 reply_id: 97374


[TOPIC: post.html]
#12

Danny

[GLOBAL: userInfoPane.html]
Danny
  • Corona Geek

  • 2,597 posts
  • Corona Staff

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


[TOPIC: post.html]
#13

Nathan B

[GLOBAL: userInfoPane.html]
Nathan B
  • Contributor

  • 173 posts
  • Corona SDK

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?
uid: 39302 topic_id: 24043 reply_id: 97378


[TOPIC: post.html]
#14

Danny

[GLOBAL: userInfoPane.html]
Danny
  • Corona Geek

  • 2,597 posts
  • Corona Staff

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 :)
uid: 84637 topic_id: 24043 reply_id: 97379


[TOPIC: post.html]
#15

Nathan B

[GLOBAL: userInfoPane.html]
Nathan B
  • Contributor

  • 173 posts
  • Corona SDK

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!
uid: 39302 topic_id: 24043 reply_id: 97385


[TOPIC: post.html]
#16

Nathan B

[GLOBAL: userInfoPane.html]
Nathan B
  • Contributor

  • 173 posts
  • Corona SDK

You changed your picture, Danny! :)

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= ?
uid: 39302 topic_id: 24043 reply_id: 98559


[TOPIC: post.html]
#17

Danny

[GLOBAL: userInfoPane.html]
Danny
  • Corona Geek

  • 2,597 posts
  • Corona Staff

Yeah I changed it :)

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
uid: 84637 topic_id: 24043 reply_id: 98563


[TOPIC: post.html]
#18

Nathan B

[GLOBAL: userInfoPane.html]
Nathan B
  • Contributor

  • 173 posts
  • Corona SDK

Okay.

Do I need to put this...
require( "ice" )
 
local settings = ice:loadBox( "settings" )

...in every file that I want to use ICE and the "settings?"
uid: 39302 topic_id: 24043 reply_id: 98568


[TOPIC: post.html]
#19

Danny

[GLOBAL: userInfoPane.html]
Danny
  • Corona Geek

  • 2,597 posts
  • Corona Staff

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
uid: 84637 topic_id: 24043 reply_id: 98570


[TOPIC: post.html]
#20

Nathan B

[GLOBAL: userInfoPane.html]
Nathan B
  • Contributor

  • 173 posts
  • Corona SDK

Alright. I thought "local" made the variable (is that what it is?) confined to that file. I'm assuming I'm wrong...
uid: 39302 topic_id: 24043 reply_id: 98572


[TOPIC: post.html]
#21

Nathan B

[GLOBAL: userInfoPane.html]
Nathan B
  • Contributor

  • 173 posts
  • Corona SDK

Back to what you replied before in reply #7, how would I use ICE to make the app store/save the data? I've been looking at ICE stuff for a bit, so you can probably answer like I know what I'm doing. ;)
uid: 39302 topic_id: 24043 reply_id: 98576


[TOPIC: post.html]
#22

Nathan B

[GLOBAL: userInfoPane.html]
Nathan B
  • Contributor

  • 173 posts
  • Corona SDK

Okay, so I've got something set up. It's not working, but I'm not getting an error. What am I missing or doing wrong?

local scores = ice:loadBox( "scores" )
local player1 = 0

--In the mute button function I have...
scores:increment( "player1", 1 )
scores:save()

--In the unmute button I have...
scores:increment( "player1", -1 )
scores:save()

--Under all the other stuff I have...
if  player1 == 1 then
       mutebutton.isVisible = false
       unmutebutton.isVisible = true
else
    	mutebutton.isVisible = true
    	unmutebutton.isVisible = false
end 

The app still mutes when I press the button, but like I explained earlier, it doesn't keep its current state after I switch to another screen and back.
uid: 39302 topic_id: 24043 reply_id: 99001


[TOPIC: post.html]
#23

TX1

[GLOBAL: userInfoPane.html]
TX1
  • Observer

  • 7 posts
  • Corona SDK

Instead of incrementing "player1" you might want to set (store) the value 1 for true and 0 for false.

for true
scores:store("player1", 1)

for false
scores:store("player1", 0)


also, make sure you're retrieving the stored value from ICE using retrieve so your code would look something l like this:
if  scores:retrieve("player1") == 1 then       mutebutton.isVisible = false       unmutebutton.isVisible = true
uid: 34029 topic_id: 24043 reply_id: 99019


[TOPIC: post.html]
#24

Nathan B

[GLOBAL: userInfoPane.html]
Nathan B
  • Contributor

  • 173 posts
  • Corona SDK

YEAH MAN! Finally! thanks a ton!!!
I'm new, and this was a challenge. ;)
uid: 39302 topic_id: 24043 reply_id: 99260


[TOPIC: post.html]
#25

se460

[GLOBAL: userInfoPane.html]
se460
  • Contributor

  • 104 posts
  • Corona SDK

Hi
How can this be done, if I am using globals ? So, when I switch scenes, the pictures will remember if the sound is on or off?

Thank you in advance :)
uid: 122802 topic_id: 24043 reply_id: 106101



[topic_controls]
Page 1 of 2 1 2
 
[/topic_controls]