LoadUtil

Kind of class:public class
Package:org.casalib.util
Inherits from:none
Version:01/08/09
Author:Aaron Clinger, Mike Creighton
Classpath:org.casalib.util.LoadUtil
File last modified:Thursday, 19 February 2009, 11:33:36
Utilities for calculating a load's speed and progress.

Summary


Class methods
  • calculateBps (bytesLoaded:uint, startTime:uint, elapsedTime:uint) : int
    • Calculates the load speed in bytes per second (Bps).
  • calculateKBps (bytesLoaded:uint, startTime:uint, elapsedTime:uint) : Number
    • Calculates the load speed in kilobytes per second (kBps).
  • calculateBufferPercent (bytesLoaded:uint, bytesTotal:uint, startTime:uint, elapsedTime:uint, lengthInMilliseconds:uint) : Percent
    • Calculates the percent the video has buffered.
  • calculateMillisecondsUntilBuffered (bytesLoaded:uint, bytesTotal:uint, startTime:uint, elapsedTime:uint, lengthInMilliseconds:uint) : uint
    • Calculates the remaining time until the video is buffered.

Class methods

calculateBps

public static function calculateBps (
bytesLoaded:uint, startTime:uint, elapsedTime:uint) : int

Calculates the load speed in bytes per second (Bps).
Parameters:
bytesLoaded:
Number of bytes that have loaded between startTime and elapsedTime.
startTime :
Time in milliseconds when the load started.
elapsedTime:
Time in milliseconds since the load started or time when load completed.
Returns:
  • Bytes per second.
Usage note:
  • This method returns BYTES per second, not bits per second.

calculateBufferPercent

public static function calculateBufferPercent (
bytesLoaded:uint, bytesTotal:uint, startTime:uint, elapsedTime:uint, lengthInMilliseconds:uint) : Percent

Calculates the percent the video has buffered.
Parameters:
bytesLoaded :
Number of bytes that have loaded between startTime and elapsedTime.
bytesTotal :
Number of bytes total to be loaded.
startTime :
Time in milliseconds when the load started.
elapsedTime :
The current time in milliseconds or time when load completed.
lengthInMilliseconds:
The total duration/length of the video in milliseconds.
Returns:
  • The percent buffered.

calculateKBps

public static function calculateKBps (
bytesLoaded:uint, startTime:uint, elapsedTime:uint) : Number

Calculates the load speed in kilobytes per second (kBps).
Parameters:
bytesLoaded:
Number of bytes that have loaded between startTime and elapsedTime.
startTime :
Time in milliseconds when the load started.
elapsedTime:
Time in milliseconds since the load started or time when load completed.
Returns:
  • Kilobytes per second.
Usage note:
  • This method returns kiloBYTES per second, not kilobits per second.

calculateMillisecondsUntilBuffered

public static function calculateMillisecondsUntilBuffered (
bytesLoaded:uint, bytesTotal:uint, startTime:uint, elapsedTime:uint, lengthInMilliseconds:uint) : uint

Calculates the remaining time until the video is buffered.
Parameters:
bytesLoaded :
Number of bytes that have loaded between startTime and elapsedTime.
bytesTotal :
Number of bytes total to be loaded.
startTime :
Time in milliseconds when the load started.
elapsedTime :
The current time in milliseconds or time when load completed.
lengthInMilliseconds:
The total duration/length of the video in milliseconds.
Returns:
  • The amount millisecond that remain before the video is buffered.