Reputation: 89
So my audio player progressbar stays at 0, and the lenght of the songs is displayed at 0:00 as well if i use javascript to manipulate songs. How can i make the progressbar update itself and the lenght of the song playing to be shown correctly.
<!doctype HTML>
<html>
<head>
<meta charset="windows-1250">
<title>Aljaževa stran</title>
<link rel="stylesheet" href="css/stil.css">
<script>
var audioElement = document.createElement('audio');
function init(){
audioElement.setAttribute('src', 'Rhythm_is_a_dancer.ogg');
}
</script>
</head>
<body onload="init()">
<audio controls="controls"></audio>
</body>
</html>
Halfway through the song ->
Upvotes: 0
Views: 39
Reputation: 10418
Give the audio
tag an id and do this:
var audioElement = document.getElementById('audio');
instead of this:
var audioElement = document.createElement('audio');
Instead of creating a new element you need to target the one you already have in the markup.
Upvotes: 1