javascript - YouTube API: When video is near end, run function -
i'm having problem trying figure out how use playback status , video length run function. api, when video starts i'm trying video length , continually check when it's near end (5 seconds). here's 1 way tried it:
setinterval(function() { // video check logic here if (player.getduration() == (player.getduration() - 5)) { $('#playback-controls').fadeout(100); clearinterval(); console.log(player.getcurrenttime()); } console.log(player.getcurrenttime()); }, 1000);
is setinterval way go it? i'm having trouble continually checking time , when value true running command.
fyi: in if(event.data==yt.playerstate.playing)
if/else statement (which runs fine alone).
thanks!
Comments
Post a Comment