Play and Stop Sound

Hi all,

i just want to create a little Soundboard App.
With GameSalad it looks quite easy.

But my Question is, i add an Actor for example "Sound 1" and another Actor with "Sound 2".

So if i hit the "Sound 1" Actor it plays the Sound, but i want to Stop the Sound if i press the "Sound 1" Actor again or if i press the "Sound 2" Actor.

I dont figure it out how i can do this.

Comments

  • ArmellineArmelline Member, PRO Posts: 5,332
    edited March 2014
    Have you tried unchecking "Run to completion"?
  • der_chintyder_chinty Member Posts: 5
    Doesnt work for me, so if i add the Rule

    When Touch is Pressed

    Do Play Sound xxx.mp3

    Else
    nothing

    So if i uncheck the "Run to Completion" i need to touch at the Actor as long as i want to hear the sound.
  • vikingviking Member, PRO Posts: 322

    I was wondering about this as well.

    I have a couple of long sound effects and I need the ability to stop the sound effect from playing when I choose, but it does not seem like I have any control over the sound effect after it has started playing. I can off course lower the sound effect volume on the device, but does not work for me since I want other sound effects to continue to play. Did anyone figure out a way to stop a sound effect from playing after it has been started?

  • allc1865allc1865 Member, PRO Posts: 777

    So you're wondering how to play the sound with one click, and then when you press the button again it stops playing the sound?

  • allc1865allc1865 Member, PRO Posts: 777

    You can watch this video:

  • vikingviking Member, PRO Posts: 322

    Thanks for the suggestion @allc1865‌, but this video only explain how you can stop playing music and not for stopping sound effects. GS treats music and sound effects very differently.

  • vikingviking Member, PRO Posts: 322

    One hard core option is to cut all longer sound effects into one second clips and then check every second if the sound effects player should play the next piece of the long SFX.

    That's a lot of work though. Would be nice to have a "Stop SFX" behavior in GS.

  • opaopa Member Posts: 35
    edited April 2014

    Make integer attribute game.active_sound

    And then add integer self.sound_number to your "button" actors and change value to 1,2,3,4...

    When button actor is released, change attribute game.active_sound to self.sound_number.

    And then make rule When game.active_sound = self.sound_number -> play sound 'xxxx'

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hi @viking‌

    Back to the original question in this thread by @der_chinty, that's relatively straightforward: in the toggled sound button, put:

    Rule: When touch is pressed
    Rule: - nested in above - When Sound01 is false
    Change Attribute Sound01 to true
    Otherwise
    Change Attribute Sound01 to false
    
    Rule: When Sound01 is true
    Play Sound Sound01 ---Run to Completion unchecked
    

    You're asking for something slightly different, but it's similar:

    When you want the first sound to start at anytime, put in a button or wherever:

    Rule: Change Attribute Sound01 to true
    
    Rule: When Sound01 is 1
    Play Sound Sound01 ---Run to Completion unchecked
    

    and in another sound button (for Sound02, for instance), to stop that first sound,

    When touch is pressed
    Rule: Change Attribute Sound01 to false
    

    Edit: typing when @opa was typing

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Sign In or Register to comment.