I worked on using the html audio tag to play some audio files. The sound plays well, but the duration property of the sound tag always returns endlessly.
I tried the accepted answer to this question, but with the same result. Tested with Chrome, IE and Firefox.
Is this an error with the audio tag, or am I missing something.
Some of the code that I use to play audio files.
Javascript function when click playbutton
function playPlayerV2(src) {
document.getElementById("audioplayerV2").addEventListener("loadedmetadata", function (_event) {
console.log(player.duration);
});
var player = document.getElementById("audioplayer");
player.src = "source";
player.load();
player.play();
}
html sound tag
<audio controls="true" id="audioplayerV2" style="display: none;" preload="auto">
Note: I am hiding the standard audio player with the intention of using a custom layout and using the player using javascript, this does not seem to be related to my problem.