html5 - JQuery - loadedmetadata listener within for loop -


I am trying to create a loop in jQuery to get the duration of different audio tracks taken from an array. It appears that an event within the loop overrides another statement to add the listener, due to the looping indefinitely and crashing the browser.

Here is the code:

  var TrackSources = new array (); Track source [0] = "music / haken.mp3"; Track source [1] = "music / drive home.mp3"; Track source [2] = "music / luminol.mp3"; Var audio playlist = document.createElement ("audio"); Audio playlist. Preload = "metadata"; Function getDurations () {var max = trackSources.length; (Var i = 0; i & lt; max;) {audioPlaylist.src = track source [i]; Audio playlist.Advent Listener ('LoadedMedataData', function () {trackdusion = audio playlistdruck; warning (trackedjan); i ++;}, false); }}   

Is there any way to do this work? Thanks!

You can try:

    

Note one side: You've mentioned jQuery but your question code is plain JS.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -