javascript - to add event listener for getting video duration in run time in videojs -
i want monitor video duration video plays using event listener. using videojs
video playback.
i came across events play
, myplayer.ispaused
fire once. myplayer
video element videojs
. upon further research got event named on
. here goes code :
myplayer.on("play", myfun); function myfun() { console.log("myplayer.currenttime()"); console.log(myplayer.currenttime()); myfun(); }
here expected give me currenttime
can see calling myfun
recursively. function getting called million times gives me starting time 0
.
i tried put myplayer.currenttime()
in setinterval
, method not trustworthy , ofcourse not idea.
i used native javascript eventlisteners not useful.
so attach event listener videoplayback sothat play duration?
the play
event fired when playback starts. if want monitor progress video correct event timeupdate. here example:
myplayer.on("timeupdate", myfun); function myfun() { console.log("myplayer.currenttime()", myplayer.currenttime()); }
Comments
Post a Comment