I am trying to get the duration of the sound using jQuery, but having difficulty getting it. The method I use is defined below
var audioElement = document.createElement('audio'); audioElement.setAttribute('src','song.mp3'); audioElement.play(); var duration = audioElement.duration; $(".songtime").html(duration);
But he says nan Does anyone have any ideas how to solve this?
josh source share