Skip to main content
Zivro
Participant
November 22, 2017
Answered

Stop sound in HTML5 Canvas

  • November 22, 2017
  • 2 replies
  • 8664 views

I have 2 frames,

frame 1    menu and background music on loop.

frame 2    different kind of menu and another type of background music

When you press a button in frame 1 it takes you to frame 2 via      gotoAndStop(1);

Problem is, the remaining instance of background music 1 plays and overlaps the background music on frame 2,

I was wondering if there was a way to kill the background music in frame 1 when the button takes you to frame 2.

​Thanks ahead!

    This topic has been closed for replies.
    Correct answer GoryGreg

    Hi,

    try createjs.Sound.stop(); in the code for frame 2. This stops all global audio.

    This page might help more...

    SoundJS v1.0.0 API Documentation : Sound

    Cheers

    Greg

    2 replies

    Legend
    November 22, 2017

    For future reference, bear in mind that some common questions have already been asked and answered many times; you just have to search for them in the little box at the top of the thread list. For example, searching for "canvas stop sound" yields these threads, all of which would have answered your question:

    Play and Stop sound in HTML5 Canvas

    HTML5 flash canva can't stop my sound with "mouseout" function

    Muting sounds in Animate CC (HMTL5 Canvas)

    Can't stop sound using javascript.

    I can't stop sound on html 5 canvas

    GoryGregCorrect answer
    Inspiring
    November 22, 2017

    Hi,

    try createjs.Sound.stop(); in the code for frame 2. This stops all global audio.

    This page might help more...

    SoundJS v1.0.0 API Documentation : Sound

    Cheers

    Greg