Playing and stopping sound

matthewadavidmatthewadavid Member Posts: 26
OK, I am starting simple. I have a game where the player can press different buttons on the screen. Each button kicks off a sound track that can play up 60 seconds. What I am having problems with is this: when a button is selected it plays the sound clip, when the next button is selected I want the first clip to stop and the new clip to start. Ideally I want to use the "touch" event.

Am I missing something?

Comments

  • matthewadavidmatthewadavid Member Posts: 26
    The problem is that I am using Sound clips. I do the following:

    Stop music
    Timer after 0.2 seconds
    play music ????

    When I get to "Play Music" I can not choose from the Library of sound clips. All I get is "resume current music" in a drop down with no other choices. Am I missing something where I am not associating sound clips in the editor correctly?
  • matthewadavidmatthewadavid Member Posts: 26
    This does not seem to be working. What I have is a series of buttons in the scene. Each button plays a sound clip. What I want to do is stop all the sounds on the screen when a button is selected. If one actor starts to play a sound and I add the "Stop Music" action to a second actor; the second action will not stop the sound from the sound from the first actor. It seems the sound and music actions are not related.
  • matthewadavidmatthewadavid Member Posts: 26
    In the latest build I can not choose an imported ogg vorbis audio as a music file. Am I missing something?
  • GameSaladGameSalad Key Master, Member Posts: 33
    ogg files are only for Play Sound behaviors.
    Play Music can only use .m4a and .aac files.
    I believe iTunes can make the appropriate file from a .ogg file.

    Yes. Sound and Music are different. If you want to stop a sound from playing have it in a rule that when true it runs the Play Sound behavior (w/o the Run To Completion selected.) Making that false will stop the Play Sound behavior if it was playing.

    Play Music/Pause Music/Stop Music are the related behaviors that only affect the music files.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    ogg files are only for Play Sound behaviors.
    Play Music can only use .m4a and .aac files.
    I believe iTunes can make the appropriate file from a .ogg file.

    Yes. Sound and Music are different. If you want to stop a sound from playing have it in a rule that when true it runs the Play Sound behavior (w/o the Run To Completion selected.) Making that false will stop the Play Sound behavior if it was playing.

    Play Music/Pause Music/Stop Music are the related behaviors that only affect the music files.
  • matthewadavidmatthewadavid Member Posts: 26
    Awesome. I will try.
  • naulboynaulboy Member Posts: 1
    I'm having a similar problem, my rules are as follows:

    new attribute for game = Initplay, to make sure the sound isn't playing when the app initiates.
    new attribute for game playmusic as discussed above in the thread.

    Then a rule for

    When Actor receives Touch / Pressed
    Change attribute game.playmusic to True

    Then a rule to let Gamesalad know to play the sound when the attribute playmusic is true

    When attribute game.playsound is True, playsound....

    Now I want the sound to toggle off if I tap while it is playing...

    I've tried a rule:

    When Attribute game.playsound is True
    and
    Actor receives event Touch / Pressed

    Change attribute game.playmusic to false

    Has anyone any ideas, much appreciated!!!
Sign In or Register to comment.