1

I add the start and end time in the html video tag and write code in video ended event. But the issue is when I use start and end time in the html video tag the ended event not working but its working fine without using start and end time.

Html Video Tag

<video style="object-fit: fill;" class="videocls" width="780" height="363" id="vid">
    <source src="/newhope/upload/1562979764.mp4#t=55,72" type="video/mp4">
</video>

Video Stop Event

$("#vid").bind("ended", function() {
    alert('hit me');
});

I want to fire this ended event when ever particular duration mention in html video tag completed.

Iñigo
  • 1,877
  • 7
  • 25
  • 55
  • checkout this answer https://stackoverflow.com/a/41047289/7035903 – shreyas d Jul 29 '19 at 06:48
  • _“I add the start and end time in the html video tag”_ – are you referring to the `#t=55,72` part of the source? That is not any kind of feature provided by HTML5 itself, AFAIK - so it presumably depends on some sort of additional library/code to make this do anything? Then you should mention what that is. – misorude Jul 29 '19 at 06:55
  • @misorude yes I am referring the same – azad chauhan Jul 29 '19 at 06:58
  • have you tried listening to the `onTimeUpdate` event? You could easily check if `this.currentTime` is === your end time. – Hermes Jul 29 '19 at 07:09
  • Thank you all for your attention. I find the solution and posted in answers – azad chauhan Jul 29 '19 at 07:46

1 Answers1

0

I find the solution for this problem. Ended event fire when the video finish completely. For this I use onpause event. When we are using the start and end interval in it pause the video not end the video so onpause event is working with this. Here is the code I am using now and its work for me

document.getElementById("vid").onpause = function() {
    alert("The video has been paused");
};