Y
Y
yahabrovec2019-06-18 22:47:42
css
yahabrovec, 2019-06-18 22:47:42

Why is metadata not loaded when changing the src of the audio element dynamically?

Hello.
Recently I decided to write my own player on electron`e and came across a problem. If the composition was initially loaded to the audio element, then by accessing audio.duration I got the duration of the song. But when the song is loaded dynamically (that is, during operation, for example, when the next or previous button is pressed), the metadata is not loaded and NaN takes off instead of the duration. Thought the page was loading too early. Hung listener onloadedmetadata on the audio element and still NaN. Although if the listener worked, it turns out that some metadata was still loaded, but there is no song duration in them.
Maybe someone knows how to solve this problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question