Compute how much your video has been buffered

@param  {Object} Buffered object
@param  {Number} Total duration
@return {Number} Percent buffered of the total duration
@private
@function bufferedPercent
548000
function bufferedPercent(buffered, duration) {
  var bufferedDuration = 0;
  var start = void 0;
  var end = void 0;

  if (!duration) {
    return 0;
  }

  if (!buffered || !buffered.length) {
    buffered = (0, _timeRanges.createTimeRange)(0, 0);
  }

  for (var i = 0; i < buffered.length; i++) {
    start = buffered.start(i);
    end = buffered.end(i);

    // buffered end can be bigger than duration by a very small fraction
    if (end > duration) {
      end = duration;
    }

    bufferedDuration += end - start;
  }

  return bufferedDuration / duration;
}
941835
function() {
            if (!api._) {
              completion(new $.Error('The plugin went away before the stream could be bound.'));
              return;
            }

            if (api._.videoWidth > 0) {
              // This fires a little too soon.
              setTimeout(completion, 200);
            }
            else {
              setTimeout(verifyStream, 500);
            }
          }
454004
function( sample ) {
		this.bufferData[ this.bufferIndex++ ] = sample;

		if ( this.bufferIndex === this.bufferLength ) {
			this.bufferIndex = 0;

			if ( this.playing ) {
				this.playing.stop();
			}
			
			this.bufferSource.buffer = this.buffer;
			this.playing = this.bufferSource;
			this.playing.start( 0 );

			this.initBuffer();
		}
	}
1087551
function(self, buffer) {
    // Set the duration.
    if (buffer && !self._duration) {
      self._duration = buffer.duration;
    }

    // Setup a sprite if none is defined.
    if (Object.keys(self._sprite).length === 0) {
      self._sprite = {__default: [0, self._duration * 1000]};
    }

    // Fire the loaded event.
    if (self._state !== 'loaded') {
      self._state = 'loaded';
      self._emit('load');
      self._loadQueue();
    }
  }
805005
function animationLoop() {
  var
    // grab current time
    t = time(),
    // calculate how many millisends we have
    fps = 1000 / next.minFPS,
    // used to flag overtime in case we exceed milliseconds
    overTime = false,
    // take current frame queue length
    length = getLength(qframe, qframex)
  ;
  // if there is actually something to do
  if (length) {
    // reschedule upfront next animation frame
    // this prevents the need for a try/catch within the while loop
    requestAnimationFrame(animationLoop);
    // reassign qframex cleaning current animation frame queue
    qframex = qframe.splice(0, length);
    while (qframex.length) {
      // if some of them fails, it's OK
      // next round will re-prioritize the animation frame queue
      exec(qframex.shift());
      // if we exceeded the frame time, get out this loop
      overTime = (time() - t) >= fps;
      if ((next.isOverloaded = overTime)) break;
    }
    // if overtime and debug is true, warn about it
    if (overTime && next.debug) console.warn('overloaded frame');
  } else {
    // all frame callbacks have been executed
    // we can actually stop asking for animation frames
    frameRunning = false;
    // and flag it as non busy/overloaded anymore
    next.isOverloaded = frameRunning;
  }
}
916951
function checkRateRange(num) {
    var numString = num.substring(0, num.length - 1);
    var parseNum = parseInt(numString);
    if (parseNum < 20) {
        throw new Error("The minimum rate is twenty percentage. Received: " + parseNum);
    }
}
1232750
function getLeastRecentlyUsed(mainDoc, lastUsedDoc) {
  var digestsToLastUsed = getDigestsToLastUsed(mainDoc, lastUsedDoc);

  var min;
  var minDigest;
  Object.keys(digestsToLastUsed).forEach(function (digest) {
    var lastUsed = digestsToLastUsed[digest];
    if (typeof min === 'undefined' || min > lastUsed) {
      min = lastUsed;
      minDigest = digest;
    }
  });
  return minDigest;
}
708511
function (buffer, start, length) {
  /*jshint bitwise:false*/

  var isNested = buffer instanceof ByteBuffer;

  this.buffer = isNested ? buffer.buffer : buffer;
  this.start = (start || 0) + (isNested ? buffer.start : 0);
  this.length = length || (this.buffer.length - this.start);
  this.offset = 0;

}
1031738
function () {
			timeLapsed += 16;
			percentage = ( timeLapsed / speed );
			percentage = ( percentage > 1 ) ? 1 : percentage;
			position = startLocation + ( distance * _easingPattern(easing, percentage) );
			window.scrollTo( 0, Math.floor(position) );
			_stopAnimateScroll(position, endLocation, animationInterval);
		}
165938
function getMaxTimeout(node){
  var timeout = 0,
    tDuration = 0,
    tDelay = 0,
    aDuration = 0,
    aDelay = 0,
    ratio = 5 / 3,
    styles ;

  if(window.getComputedStyle){

    styles = window.getComputedStyle(node),
    tDuration = getMaxTime( styles[transitionProperty + 'Duration']) || tDuration;
    tDelay = getMaxTime( styles[transitionProperty + 'Delay']) || tDelay;
    aDuration = getMaxTime( styles[animationProperty + 'Duration']) || aDuration;
    aDelay = getMaxTime( styles[animationProperty + 'Delay']) || aDelay;
    timeout = Math.max( tDuration+tDelay, aDuration + aDelay );

  }
  return timeout * 1000 * ratio;
}
144221
def total_time(self):
        """"""
        now_playing = self._setstate.nowPlayingInfo
        if now_playing.HasField('duration'):
            return int(now_playing.duration)

        return None
1372425
function parse_youtube(url_path, $) {
  // Durations are ISO 8601 format: "PT48M42S"
  const duration_regex = /^PT(?:(\d+)H)?(?:(\d+)M)?(\d+)S$/;

  if (url_path.match("^\\/watch") === null) {
    return parse_generic(url_path, $);
  }

  // TODO: only do this for paths that make sense
  const title = $("meta[itemprop=name]").attr("content");
  const views = $("#watch7-views-info > div.watch-view-count").text().split(" ")[0] || 0;
  let likes = $("#watch-header .like-button-renderer span.yt-uix-button-content").first().text().replace(/[\s,]/g, "") || 0;
  let dislikes = $("#watch-header .like-button-renderer span.yt-uix-button-content").get(3);
  dislikes = $(dislikes).text().replace(/[\s,]/g, "") || 0;
  likes = parseInt(likes, 10);
  dislikes = parseInt(dislikes, 10);
  const rating = Math.round(100 * likes / (likes + dislikes));
  let duration = $("meta[itemprop=duration]").attr("content");
  let matches = duration_regex.exec(duration);
  if (matches) {
    matches = {
      hours: parseInt(matches[1], 10),
      minutes: parseInt(matches[2], 10),
      seconds: parseInt(matches[3], 10),
    };
    // Youtube often sets hours to zero and minutes to >= 60
    if (matches.minutes >= 60) {
      matches.hours = Math.floor(matches.minutes / 60);
      matches.minutes = matches.minutes % 60;
    }
    if (matches.minutes < 10) {
      matches.minutes = "0" + matches.minutes;
    }
    if (matches.seconds < 10) {
      matches.seconds = "0" + matches.seconds;
    }
    duration = util.format("%s:%s", matches.minutes, matches.seconds);
    if (matches.hours) {
      duration = util.format("%s:%s", matches.hours, duration);
    }
  } else {
    duration = "";
  }
  return util.format("%s %s %s views %s%% like", title, duration, views, rating);
}
804170
function() {
            var
              barWidth       = $bar.width(),
              totalWidth     = $module.width(),
              minDisplay     = parseInt($bar.css('min-width'), 10),
              displayPercent = (barWidth > minDisplay)
                ? (barWidth / totalWidth * 100)
                : module.percent
            ;
            return (settings.precision > 0)
              ? Math.round(displayPercent * (10 * settings.precision)) / (10 * settings.precision)
              : Math.round(displayPercent)
            ;
          }
238767
def percent
      return unless (buffer = accept_stripped :exp_percent)
      match_start = buffer[-1]
      match_name = :"percent#{match_start}"

      unless Tokens[match_name]
        match_end = Tokens.bracket(match_start) || match_start

        match_inner = "\\#{match_start}"
        match_inner += "\\#{match_end}" unless match_end == match_start

        pattern = /(((?:[^#{match_inner}\\]|\\.)*?)#{'\\' + match_end})/

        Tokens[match_name] = pattern
      end

      buffer += accept match_name
      buffer
    end
410660
@Override
  public StringBuilder appendToBuffer(StringBuilder buf) {
    String processedString = Integer.toString(getProcessed());
    int percentage = (int) (getProcessed() * 100.0 / total);
    buf.append(getTask());
    buf.append(": ");
    for(int i = 0; i < totalLength - processedString.length(); i++) {
      buf.append(' ');
    }
    buf.append(getProcessed());
    buf.append(" [");
    if(percentage < 100) {
      buf.append(' ');
    }
    if(percentage < 10) {
      buf.append(' ');
    }
    buf.append(percentage);
    buf.append("%]");
    if(ratems > 0. && getProcessed() < total) {
      buf.append(' ');
      int secs = (int) Math.round((total - getProcessed()) / ratems / 1000. + .2);
      if(secs > 300) {
        buf.append(secs / 60);
        buf.append(" min remaining");
      }
      else {
        buf.append(secs);
        buf.append(" sec remaining");
      }
    }
    return buf;
  }
226233
function initBufferMode () {
		//how many times output buffer contains input one
		let FOLD = 2;

		//buffer source node
		node = context.createBufferSource()
		node.loop = true;
		node.buffer = util.create(samplesPerFrame * FOLD, channels, {context: node.context})

		//output buffer
		let buffer = node.buffer;

		//audio buffer realtime ticked cycle
		//FIXME: find a way to receive target starving callback here instead of unguaranteed timeouts
		setTimeout(tick)

		node.start()

		//last played count, position from which there is no data filled up
		let lastCount = 0;

		//time of start
		//FIXME: find out why and how this magic coefficient affects buffer scheduling
		let initTime = context.currentTime;

		return node;

		//tick function - if the half-buffer is passed - emit the tick event, which will fill the buffer
		function tick (a) {
			if (isStopped) return;

			let playedTime = context.currentTime - initTime;
			let playedCount = playedTime * sampleRate;

			//if offset has changed - notify processor to provide a new piece of data
			if (lastCount - playedCount < samplesPerFrame) {
				//send queued data chunk to buffer
				util.copy(shift(samplesPerFrame), buffer, lastCount % buffer.length)

				//increase rendered count
				lastCount += samplesPerFrame;

				//if there is a holding pressure control - release it
				if (release) {
					let cb = release;
					release = null;
					cb()
				}

				//call tick extra-time in case if there is a room for buffer
				//it will plan timeout, if none
				tick()
			}
			//else plan tick for the expected time of starving
			else {
				//time of starving is when played time reaches (last count time) - half-duration
				let starvingTime = (lastCount - samplesPerFrame) / sampleRate;
				let remainingTime = starvingTime - playedTime;
				setTimeout(tick, remainingTime * 1000)
			}
		}
	}
1205827
function(buffer){

                    //Deserialize binary data into a JSON object
                    var data = micro.toJSON(buffer);
                    var type = data._type;
                    delete data._type;

                    switch (type)
                    {
                        case "Ping" :
                            var numPings = data.timestamps.length;

                            //Ping a minimum of number of times, before calculating the latency
                            if (numPings < MAX_PINGS){
                                ping(data);
                            }
                            else if (numPings == MAX_PINGS){
                                //Calculate this connections average latency and send it to the client
                                data.latency = calculateLatency(data.timestamps);
                                console.log(data.latency);
                                ping(data);

                                //If we haven't initialized yet, add this connection to the server zone
                                if (!initialized){
                                    serverZone.add(connection);
                                    initialized = true;
                                }
                            }

                            break;

                        case "PlayerUpdate":
                            //Set the player update id to the connection id to prevent clients from updating other players
                            data.id = connection.id;
                            serverZone.updatePlayer(data);
                            break;

                        default:
                            console.warn("Unexpected Schema Type Received: "+type);
                            break;
                    }
                }