-1

I have some health related videos on my website and I need to track how long the viewer has watched a video so that I can know how interesting the video was for the user. The scenarios that can be considered and help in tracking "how long" can be -

a) If user accessed a different page or some other section in the same page b) If user intentionally stopped/paused the video c) If user minimizes or closes the page when the video is still playing

I am looking for a JQuery plugin that can verify all the above scenarios rather than coding for each of the scenario (using events and handlers) and finally integrating them. Can any one suggest such kind of plugin that can help and serve my purpose.

Thanks in advance..!

1 Answers1

1

HTML

<video
id="video-active"
class="video-active"
width="640"
height="390"
controls="controls">
<source src="myvideo.mp4" type="video/mp4">

<div id="current">0:00</div>
<div id="duration">0:00</div>

JavaScript

$(document).ready(function()
{
  $("#video").on("timeupdate", function(event)
  {  
    onTrackedVideoFrame(this.currentTime, this.duration);
  });
}

function onTrackedVideoFrame(currentTime, duration)
{
  $("#current").text(currentTime);
  $("#duration").text(duration);
}
Nachiket
  • 620
  • 6
  • 23