B2G/gaia/shared/js/media/video_player.js
// Set the elapsed time and slider position
Set the elapsed time and slider position
Set the elapsed time and slider position
function updateTime() {
    if (!controlsHidden) {
      elapsedText.textContent = formatTime(player.currentTime);
      if (player.duration === Infinity || player.duration === 0)
        return;
      var percent = (player.currentTime / player.duration) * 100 + '%';
      elapsedBar.style.width = percent;
      playHead.style.left = percent;
    }
    if (!endedTimer) {
      if (!dragging && player.currentTime >= player.duration - 1) {
        var timeUntilEnd = (player.duration - player.currentTime + .5);
        endedTimer = setTimeout(ended, timeUntilEnd * 1000);
      }
    }
    else if (dragging && player.currentTime < player.duration - 1) {
      clearTimeout(endedTimer);
      endedTimer = null;
    }
  }
function updateTime ( ) { if ( ! controlsHidden ) { elapsedText . textContent = formatTime ( player . currentTime ) ; if ( player . duration === Infinity || player . duration === 0 ) return ; var percent = ( player . currentTime / player . duration ) * 100 + '%' ; elapsedBar . style . width = percent ; playHead . style . left = percent ; } if ( ! endedTimer ) { if ( ! dragging && player . currentTime >= player . duration - 1 ) { var timeUntilEnd = ( player . duration - player . currentTime + .5 ) ; endedTimer = setTimeout ( ended , timeUntilEnd * 1000 ) ; } } else if ( dragging && player . currentTime < player . duration - 1 ) { clearTimeout ( endedTimer ) ; endedTimer = null ; } }
Set the elapsed time and slider position
Set the elapsed time and slider position
// 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. // 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