So i have this Twitch video (past broadcast) that i want to show on my webpage. Now i want to show the current time of the video when it is playing. There is this function that returns this time but i can't get it to show in "realtime" (you actually see it running). I can only get it to show the current time after i perfom an action.
<script src= "http://player.twitch.tv/js/embed/v1.js"></script>
<div id="play"></div>
<div id="time"><span>kp</span></div>
<script type="text/javascript">
var options = {
width: 854,
height: 480,
video: "v113523217"
};
var player = new Twitch.Player("play", options);
//this just returns 0
var test = player.getCurrentTime();
$('#time').append(test);
//this works
$('span').click(function() {
var test = player.getCurrentTime();
$('#time').html(test);
});
</script>
Is it possible to show a running timer of the current time of the player? I might also want to do some stuff depending on the remaining time.
I think you want to update every second:
setInterval(function(){
var test = player.getCurrentTime();
$('#time').html(test);
//if you want to show something after 1 minute (for example):
if(test>60000&&test<61000){
alert("one min");
}
},1000);