How can I play music when returning to a screen?

I have a settings screen where a checkbox turns on/turns off music (playmusic true or false). When I come back from the settings screen to the main screen how would I immediately have music turn based on the playmusic logical variable? thanks.

Read this first ... and then show your blocks:

Btw, what means "logical variable"?

A logical variable is a variable that takes on the form true/false.

So say I set playmusic to be true or false. When I return from a "settings" screen to the "main" screen I want something that says "if playmusic=true then playmusic". Should I put that in a screen initialize setting?

A boolean variable then :wink:

1 Like

I would keep settings like that in a separate TinyDB NameSpace, with tags for

  • Volume
  • Play/Stop
  • Preferred music
  • etc

Encapsulate the checking of the Settings TinyDB and the adjustments to the Player component into a CheckSoundSettings procedure, to be called from each Screen's Initialize and When Other Screen Closed event blocks.

I sort of do that and you raise a question I haven't checked yet.........

When I go back from my settings screen I do write items to a tinydb.

o Is there a "When Other Screen Closed event block." haven't seen that.
o If I am at screen1, go to screen 2, close and go back to screen 1, is scren1's "screen initialize" fired or is "Screen initialize" only fired the very first time that screen is ever reached (that is it screen initialize fired everytime i go to that screen or just the first time?) Thanks!

Try this: playAfterSwitchScreen.aia (143.7 KB)

Screen1:

Screen: Settings

or this (with Checkbox):

grafik

1 Like