Skip to main content
francescot
Inspiring
January 26, 2021
Answered

Sound effects html5 canvas

  • January 26, 2021
  • 1 reply
  • 1450 views

I'm trying to learn the soundJS in order to add an effect on loading a frame. Struggling to get it to work.

Is there a particular method for html5 to add sound effects as in actionscript format?

I've tried the following without success:

createjs.Sound.on("fileload", this.loadHandler, this);
 createjs.Sound.registerSound("Blop.wav", "bloop");
 function loadHandler(event) {
     // This is fired for each sound that is registered.
     var instance = createjs.Sound.on("bloop");  
     instance.on("complete", this.handleComplete, this);
     instance.volume = 0.5;
 }

 

    This topic has been closed for replies.
    Correct answer kglad

    It's in the library with a linkage "bloop".

    Essentially I'd like the sound to play when particular boxes appear in the timeline, if possible.


    in the actions panel at the frame where you want the sound to play:

     

    var sound1 = createjs.Sound.createInstance("bloop");

    sound1.play();

     

    or

     

    createjs.Sound.createInstance("bloop").play();

     

    or 

     

    createjs.Sound.play("bloop");

    1 reply

    kglad
    Community Expert
    Community Expert
    January 26, 2021

    what do you mean by "loading a frame"?

     

    do you mean you want a sound to play when the playhead enters a particular frame?  or do you mean you are actually loading something from outside your project and you want a sound to play when loading is progressing or when loading is complete or something else?

    francescot
    Inspiring
    January 26, 2021

    Sorry when it enters a particular frame.

     

    Thanks

    kglad
    Community Expert
    Community Expert
    January 26, 2021

    is the sound an external file (eg, Blop.wav) that you want to load during run-time (more coding and forethought needed) or is the sound imported into your library (easier to code and implement)?