title: JavaScript Video/Audio Interruption Event
body: <p>My goal is to collect the total time the user views a given media, in this case, video. I've read through both <a href="https://www.w3schools.com/tags/ref_av_dom.asp" rel="nofollow noreferrer">w3schools</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Media_events" rel="nofollow noreferrer">MDN's</a> to identify whether there's an event to handle the following scenario:</p>
  
  <p>A user is watching a video, but before having completed the video, they close the browser. In this scenario, <code>ended</code> isn't triggered, and in my case, calling <code>currentTime</code> is operationally expensive since it means we have to call our servers every second to pass the seconds information for the video for each user that's viewing the video.</p>
  
  <p>When the browser closes, we have no way to pass any information to our analytics server since the session is stopped.</p>
  
  <p>Are there any events that can be triggered from the browser to the server to inform us whether the video was:</p>
  
  <ol>
  <li>Interrupted?</li>
  <li>How far did the user see the video?</li>
  </ol>