J
J
JohnDaniels2016-05-17 08:56:16
JavaScript
JohnDaniels, 2016-05-17 08:56:16

Why is audio.duration different in FF and chrome?

var  audio = document.getElementById("player");
...
$('#player').attr('src', 'path/to/audio.mp3');
...
audio.addEventListener("loadeddata", function () {
        var duration = audio.duration;
        console.log (duration );
    });

chrome:
7a915ebaea47467aa22d14b731881d6b.png
Fifefox:
63e7770cfa4743249e86c2d4599966a8.png
Chrome shows the correct duration. what's the matter?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Ineshin, 2016-05-17
@IonDen

Better use "canplaythrough". Usually "loadeddata" fires too soon.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question