Skip to main content
Participating Frequently
January 4, 2021
Question

Why does sound preclude downloading from a server?

  • January 4, 2021
  • 1 reply
  • 603 views

   I have developed a series of programs for use by my students. They use a range of platforms and browsers, so I put the programs on a server and they work perfectly except for those that have sound. If I erase the sound code below (or erase the sounds folder) they download, but if I include the sound code then all I get is a blank screen. Also, it works when I publish it on my computer.

   Here is the part of the code that seems to be providing the problem:

for (i = 0; 1 <= 60; i++)
{
if (i == 14){var audio1 = createjs.Sound.play("beep");}
if (i == 39){var audio2 = createjs.Sound.play("beep");}

}

   The above is part of additional lines of code that draws on the screen. The student clicks the mouse when they hear the sound (beep), which is located in the library as beep.wav (linkage = "beep"). 

    This topic has been closed for replies.

    1 reply

    kglad
    Community Expert
    Community Expert
    January 4, 2021

    well, that (your code) is a problem:

     

    to understand why, you need to know your for-loop executes from beginning to end before anything is shown on stage.  ie, for practical purposes all 61 loops occur at that same time.  

     

    you can't possibly want that to happen.  so you need to change your code.

     

    what it should be changed to, i don't know because i can't even figure out what you want to occur.

    Participating Frequently
    January 4, 2021

       I am drawing an electrocardiogram trace by drawing a series of short connected lines on a virtual screen. Each ECG 'cycle' takes 60 of these short lines.. When i = 14 and i = 39, I aim to play a sound which represents the heart sounds. The students click their mouse when they hear each sound to correlate the ECG with the heart sound.

    kglad
    Community Expert
    Community Expert
    January 4, 2021

    you need to convert from line segments to time (in ms).  you can then use a Ticker loop to trigger the beep every x ms, 

    EaselJS v1.0.0 API Documentation : Ticker (createjs.com).  

     

    (but you should have two different sounds, for a normal heart.)