Sha256: 4a60c5e1454c41d7e4bf3a5baccb66cc972b739e02646bc4e45771f7067f809a

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

// look for maximal buffered time range instead of first
vjs.Player.prototype.buffered = function(){
  var buffered = this.techGet('buffered'),
      max = 0,
      start = 0,
      // Default end to 0 and store in values
      end = this.cache_.bufferEnd = this.cache_.bufferEnd || 0;

  if (buffered && buffered.length > 0) {
    for (var i = 0; i < buffered.length; i++) {
      if (buffered.end(i) > max) {
        max = buffered.end(i);
      }
    }

    if (max !== end) {
      end = max;
      // Storing values allows them be overridden by setBufferedFromProgress
      this.cache_.bufferEnd = max;
    }
  }

  return vjs.createTimeRange(start, end);
};

// If end is after duration return buffered percent 0
vjs.Player.prototype.bufferedPercent = function(){
  // Sometimes duration is rounded to less digits than end causing end
  // to be just a little bit greater. Therefore round.
  if (this.duration() && Math.floor(this.buffered().end(0)) <= this.duration()) {
    return this.buffered().end(0) / this.duration();
  }
  else {
    return 0;
  }
};

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pageflow-0.4.0 app/assets/javascripts/pageflow/video_player/player_buffered_patch.js
pageflow-0.3.0 app/assets/javascripts/pageflow/video_player/player_buffered_patch.js
pageflow-0.2.1 app/assets/javascripts/pageflow/video_player/player_buffered_patch.js
pageflow-0.2.0 app/assets/javascripts/pageflow/video_player/player_buffered_patch.js
pageflow-0.1.0 app/assets/javascripts/pageflow/video_player/player_buffered_patch.js
pageflow-0.0.5 app/assets/javascripts/pageflow/video_player/player_buffered_patch.js
pageflow-0.0.4 app/assets/javascripts/pageflow/video_player/player_buffered_patch.js
pageflow-0.0.3 app/assets/javascripts/pageflow/video_player/player_buffered_patch.js
pageflow-0.0.2 app/assets/javascripts/pageflow/video_player/player_buffered_patch.js
pageflow-0.0.1 app/assets/javascripts/pageflow/video_player/player_buffered_patch.js