Skip to main content
Participant
October 20, 2020
Answered

How to play and stop multi audio in html canvas

  • October 20, 2020
  • 1 reply
  • 681 views

Need an idea of ​​playing multiple sounds in html5 canvas.

    This topic has been closed for replies.
    Correct answer JoãoCésar17023019

    Hi.

     

    Perhaps this example will help you.

    https://github.com/joao-cesar/adobe/tree/master/animate%20cc/html5_canvas/narrated_story

     

    Just call your sounds like this:

    this.playSound("Voice0", "voice", false, { volume: 0.2, loop: -1 });

     

    The first argument is the linkage name of your sound in the Library.

     

    The second argument is a custom id you pass to create categories for your sounds. For example: "bgm", "sfx", "narration", and so on.

     

    The third argument stops the previous playing sound in the same category.

     

    The fourth argument are play props. You can see more about these props here:

    https://createjs.com/docs/soundjs/classes/PlayPropsConfig.html

     

    I hope these help.

     

    Regards,

    JC

    1 reply

    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    October 20, 2020

    Hi.

     

    Perhaps this example will help you.

    https://github.com/joao-cesar/adobe/tree/master/animate%20cc/html5_canvas/narrated_story

     

    Just call your sounds like this:

    this.playSound("Voice0", "voice", false, { volume: 0.2, loop: -1 });

     

    The first argument is the linkage name of your sound in the Library.

     

    The second argument is a custom id you pass to create categories for your sounds. For example: "bgm", "sfx", "narration", and so on.

     

    The third argument stops the previous playing sound in the same category.

     

    The fourth argument are play props. You can see more about these props here:

    https://createjs.com/docs/soundjs/classes/PlayPropsConfig.html

     

    I hope these help.

     

    Regards,

    JC

    ChinJunGAuthor
    Participant
    October 21, 2020

    @JoãoCésar17023019 

    Thank you for the reply!

    JoãoCésar17023019
    Community Expert
    Community Expert
    October 21, 2020

    You're welcome!