H5中通过JS获取音频时长



function duration()
{
    var audio = document.getElementById("audio-element");
    if(audio.readyState > 0) 
    {
        var minutes = parseInt(audio.duration / 60, 10);
        var seconds = parseInt(audio.duration % 60);
        
        alert(minutes+":"+seconds);
    }
}

 

你可能感兴趣的:(前端)