javascript - HTML5 video - detected when current time equals a certain value -
i trying detect when current time of html video equals particular value, think going wrong way.
js load video source (works fine)
document.queryselector("#videobox > source").src = $scope.videourl; var video = document.getelementbyid("videobox"); js detect current time
if (video.currenttime == 0.2){ alert("time reached!"); } if check currenttime==0 correctly detected before video starts, doesn't work other durations. appreciate help.
when document loaded if statement checked once , not again. if check video.currenttime == 0 true video.currenttime == 0.2 false, try this:
var interval = setinterval(checktime, 100); function checktime(){ if(math.floor(video.currenttime) == 2){ alert("time reached!"); clearinterval(interval); } } in way check time every 100 miliseconds , if time 0.2 interval stoped
Comments
Post a Comment