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

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -