L
L
Lakewake2011-09-10 01:55:30
JavaScript
Lakewake, 2011-09-10 01:55:30

html5 audio - js , "load" event does not occur

The problem with the Audio element is that I dynamically create it in js, but the load event does not occur:

var snd = new Audio("sound.wav");

   snd.preload = "auto";

   snd.addEventListener("load", function() {
                    console.log('loaded');
   },false);

   snd.load();


Tried different variations of .preload, .play, .load, the event is silent. How to track the completion of the download of an audio file?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mariofag, 2011-09-10
@mariofag

No, there is no such possibility in the standard.
The fact is that some browsers do not download the file completely until it is needed, so it is not clear when to call event. However, you can use snd.play() at any time, regardless of the progress of the download.

K
Konstantin Kitmanov, 2011-09-10
@k12th

Maybe you need to use the Gatling scheme ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question