Reputation: 621
This is to do with the youtube api and getting the current time.
var currenttime = ytplayer.getCurrentTime();
document.getElementById('currenttime').innerHTML = currenttime;
<p id="currenttime"></p>
How would I make it keep updating the current time so that you can see the time going up on the screen while the video is playing?
Upvotes: 1
Views: 312
Reputation: 8156
You could use a timer that will fetch the time every one second.
var timer = setInterval(function(){
document.getElementById("currenttime").innerHTML = currenttime;
},1000);
Note:
Take a closer look (on the difference between setInterval and setTimeout):
setTimeout or setInterval?
Upvotes: 4