Unable To Change The Sound

My Blocks:



If I offSoundSwitch off and then I go to the Screen2, after that if I come back from Screen2 to Current Screen, then the sound starts automatically while the Current Screen is showing offSoundSwitch off. So how can I pause/stop the sound when I come back from Screen2 to Current Screen and Current Screen is showing offSoundSwitch off?

8172fc99fb676c076d8a57ab3423e7a8f4160e8d_2_690x401

Could you explain these mysterious blocks to us?

how to use the manager screen method to switch screens including the OtherScreenClosed event see here The recommended method of switching screens in App Inventor

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

I am unable to give you explanation because I am also confused.
Screenshot (127)
When I click on Back button or click on Screen.BackPressed, then it returns to Screen3 but if on Screen3 OffSoundSwitch is off, then also it runs the sound. I want that if on Screen3 OffSoundSwitch is off then it does not run the sound and also if on Screen3 OnSoundSwitch is on then it runs the sound.
So please help me in doing this.

This did not work.

Can you also please elaborate on why you are using TWO switches? One should be enough. With one you could do something like this:
image

unfortunately without seeing your updated blocks we do not know, what you might have learned from my example...

your blocks in the OtherSreenClosed event do not make any sense...
you might want to elaborate, what exctly you are trying to do after coming back from another screen

Taifun

I did not use switch in Back button and in Screen2.BackPressed. Please again check the images of my blocks.

Sorry, I didn't quite understand you. Could you please rephrase that?

Yes, sure. I have used two switches because I have to change the image on the Main Screen not on Screen2. So, I am unable to use switches on Screen2. Please tell me that there is any way in which I can change the image in a switch (Another image when switch is on and another image when switch is off).

There is nothing to stop you having two switches on any screen, along with your ability to code them correctly to do what you want them to do

Okay, I understand your point but please help me in my problem.

What have you tried? Why are you unable to use a switch to set an image on Screen2. Show your relevant blocks/screens as appropriate.

No that is not my problem. Please check my question and first post.

Stop the sound BEFORE you switch screens

I read your original post several times. Sorry, I still don't understand what you want to do.

You can try this example. It might do what you want.Flush.aia (56.4 KB)

If it doesn't meet your expectations, experiment and modify it the way you want it to work.

You could use a CheckBox and a virtual screen and make this activity real simple but you insist in switching real Screens, so take a look.

But I want that the sound stops only when the OffSoundSwitch is off otherwise the sound would keep playing.

Stop the sound when OffSoundSwitch is off and do this before you switch screens.

Work through the flow and the logic of what you are doing / want to do, then apply this to the blocks.

Edit in the question: If I used two switches (OnSoundSwitch and OffSoundSwitch) on the Screen1. If OnSoundSwitch is on, then I will hear the sound and OffSoundSwitch is off, then I will not hear the sound. I used two switches because I want to display image1 when OnSoundSwitch is on and display image2 when OffSoundSwitch is off. If OffSoundSwitch is off (means that OnSoundSwitch is also off) and I am on Screen2 and then return to Screen1, then I hear the sound on Screen1 when the OffSoundSwitch is off but when I on the switch, then off the switch, then I will not hear the sound. But I want that I will not hear the sound if I switch to Screen1 from Screen2 and also OffSoundSwitch is off . So please anyone help me in solving this problem.
Please Help !!

Post the aia and describe precisely which steps are to be carried out and what happens / should happen in each case.

Steps:

  1. open app
  2. click button, check / uncheck CheckBox (Switch) -> result
  3. switch to Screen x -> result
  4. switch back to screen y -> result
    ...