apps/video/js/video.js
// Update the progress bar and play head as the video plays
Update the progress bar and play head as the video plays
Update the progress bar and play head as the video plays
function timeUpdated() {
  if (controlShowing) {
    if (dom.player.duration === Infinity || dom.player.duration === 0) {
      return;
    }
    var percent = (dom.player.currentTime / dom.player.duration) * 100 + '%';
    dom.elapsedText.textContent = formatDuration(dom.player.currentTime);
    dom.elapsedTime.style.width = percent;
    if (!dragging)
      dom.playHead.style.left = percent;
  }
  if (!endedTimer) {
    if (!dragging && dom.player.currentTime >= dom.player.duration - 1) {
      var timeUntilEnd = (dom.player.duration - dom.player.currentTime + .5);
      endedTimer = setTimeout(playerEnded, timeUntilEnd * 1000);
    }
  } else if (dragging && dom.player.currentTime < dom.player.duration - 1) {
    clearTimeout(endedTimer);
    endedTimer = null;
  }
}
function timeUpdated ( ) { if ( controlShowing ) { if ( dom . player . duration === Infinity || dom . player . duration === 0 ) { return ; } var percent = ( dom . player . currentTime / dom . player . duration ) * 100 + '%' ; dom . elapsedText . textContent = formatDuration ( dom . player . currentTime ) ; dom . elapsedTime . style . width = percent ; if ( ! dragging ) dom . playHead . style . left = percent ; } if ( ! endedTimer ) { if ( ! dragging && dom . player . currentTime >= dom . player . duration - 1 ) { var timeUntilEnd = ( dom . player . duration - dom . player . currentTime + .5 ) ; endedTimer = setTimeout ( playerEnded , timeUntilEnd * 1000 ) ; } } else if ( dragging && dom . player . currentTime < dom . player . duration - 1 ) { clearTimeout ( endedTimer ) ; endedTimer = null ; } }
Update the progress bar and play head as the video plays
Update the progress bar and play head as the video plays
// We can't update a progress bar if we don't know how long // the video is. It is kind of a bug that the <video> element // can't figure this out for ogv videos. // Don't move the play head if the user is dragging it. // Since we don't always get reliable 'ended' events, see if // we've reached the end this way. // See: https://bugzilla.mozilla.org/show_bug.cgi?id=783512 // If we're within 1 second of the end of the video, register // a timeout a half a second after we'd expect an ended event. // If there is a timer set and we drag away from the end, cancel the timer