# Global

##

### Members

#### (constant) duration

Calculates the duration of a playlist. If a start and end index are specified, the duration will be for the subset of the media timeline between those two indices. The total duration for live playlists is always Infinity.

Source:
  - playlist.js, line 161

#### (constant) getMediaInfoForTime_

Determine the index and estimated starting time of the segment that contains a specified playback position in a media playlist.

Source:
  - playlist.js, line 391

#### (constant) seekable

Calculates the interval of time that is currently seekable in a playlist. The returned time ranges are relative to the earliest moment in the specified playlist that is still available. A full seekable implementation for live streams would need to offset these values by the duration of content that has expired from the stream.

Source:
  - playlist.js, line 323

#### (constant) sumDurations

Calculate the time between two indexes in the current playlist neight the start- nor the end-index need to be within the current playlist in which case, the targetDuration of the playlist is used to approximate the durations of the segments

Source:
  - playlist.js, line 201

#### systemBandwidth

`systemBandwidth` is a combination of two serial processes bit-rates. The first is the network bitrate provided by `bandwidth` and the second is the bitrate of the entire process after that - decryption, transmuxing, and appending - provided by `throughput`. Since the two process are serial, the overall system bandwidth is given by: sysBandwidth = 1 / (1 / bandwidth + 1 / throughput)

Source:
  - videojs-contrib-hls.js, line 479

#### (constant) utils

utils to help dump binary data to the console

Source:
  - bin-utils.js, line 66

### Methods

#### abort(done)

Aborts the current segment and resets the segment parser.

##### Parameters:

Name | Type | Description
--- | --- | ---
`done` | function | function to call when done

Source:
  - source-updater.js, line 60
See:
  - http://w3c.github.io/media-source/#widl-SourceBuffer-abort-void

#### abort()

abort anything that is currently doing on with the SegmentLoader and reset to a default state

Source:
  - segment-loader.js, line 188

#### appendBuffer(bytes, done)

Queue an update to append an ArrayBuffer.

##### Parameters:

Name | Type | Description
--- | --- | ---
`bytes` | ArrayBuffer |
`done` | function | the function to call when done

Source:
  - source-updater.js, line 73
See:
  - http://www.w3.org/TR/media-source/#widl-SourceBuffer-appendBuffer-void-ArrayBuffer-data

#### backwardDuration(playlist, endSequence)

walk backward until we find a duration we can use or return a failure

##### Parameters:

Name | Type | Description
--- | --- | ---
`playlist` | Playlist | the playlist to walk through
`endSequence` | Number | the mediaSequence to stop walking on

Source:
  - playlist.js, line 27

#### buffered()

Indicates what TimeRanges are buffered in the managed SourceBuffer.

Source:
  - source-updater.js, line 84
See:
  - http://www.w3.org/TR/media-source/#widl-SourceBuffer-buffered

#### bufferIntersection(bufferA, bufferB) → {TimeRanges}

Calculate the intersection of two TimeRanges

##### Parameters:

Name | Type | Description
--- | --- | ---
`bufferA` | TimeRanges |
`bufferB` | TimeRanges |

Source:
  - ranges.js, line 153

##### Returns:

The interesection of `bufferA` with `bufferB`

Type
  TimeRanges

#### byterangeStr()

Turns segment byterange into a string suitable for use in HTTP Range requests

Source:
  - segment-loader.js, line 47

#### calculateBufferedPercent(segmentRange, referenceRange, currentTime, buffered) → {Number}

Calculates the percentage of `segmentRange` that overlaps the `buffered` time ranges.

##### Parameters:

Name | Type | Description
--- | --- | ---
`segmentRange` | TimeRanges | the time range that the segment covers adjusted according to currentTime
`referenceRange` | TimeRanges | the original time range that the segment covers
`currentTime` | Number | time in seconds where the current playback is at
`buffered` | TimeRanges | the currently buffered time ranges

Source:
  - ranges.js, line 227

##### Returns:

percent of the segment currently buffered

Type
  Number

#### calculateExpiredTime(playlist, expiredSync, segmentSync) → {Number}

Calculates the amount of time expired from the playlist based on the provided sync points.

##### Parameters:

Name | Type | Description
--- | --- | ---
`playlist` | Object | a media playlist object
`expiredSync` | Object | null | sync point representing most recent segment with timing sync data that has fallen off the playlist
`segmentSync` | Object | null | sync point representing the first segment that has timing sync data in the playlist

Source:
  - playlist.js, line 259

##### Returns:

the amount of time expired from the playlist

Type
  Number

#### checkBuffer_(buffered, playlist, mediaIndex, hasPlayed, currentTime, syncPoint) → {Object}

Determines what segment request should be made, given current playback state.

##### Parameters:

Name | Type | Description
--- | --- | ---
`buffered` | TimeRanges | the state of the buffer
`playlist` | Object | the playlist object to fetch segments from
`mediaIndex` | Number | the previous mediaIndex fetched or null
`hasPlayed` | Boolean | a flag indicating whether we have played or not
`currentTime` | Number | the playback position in seconds
`syncPoint` | Object | a segment info object that describes the

Source:
  - segment-loader.js, line 549

##### Returns:

a segment request object that describes the segment to load

Type
  Object

#### clamp(num, start, end) → {Number}

Clamps a value to within a range

##### Parameters:

Name | Type | Description
--- | --- | ---
`num` | Number | the value to clamp
`start` | Number | the start of the range to clamp within, inclusive
`end` | Number | the end of the range to clamp within, inclusive

Source:
  - ranges.js, line 20

##### Returns:

Type
  Number

#### createTransferableMessage(message) → {Object}

Creates an object for sending to a web worker modifying properties that are TypedArrays into a new object with seperated properties for the buffer, byteOffset, and byteLength.

##### Parameters:

Name | Type | Description
--- | --- | ---
`message` | Object | Object of properties and values to send to the web worker

Source:
  - bin-utils.js, line 33

##### Returns:

Modified message with TypedArray values expanded

Type
  Object

#### DecrypterWorker(self)

Our web worker interface so that things can talk to aes-decrypter that will be running in a web worker. the scope is passed to this by webworkify.

##### Parameters:

Name | Type | Description
--- | --- | ---
`self` | Object | the scope for the web worker

Source:
  - decrypter-worker.js, line 13

#### detectEndOfStream(playlist, mediaSource, segmentIndex) → {Boolean}

Determines if we should call endOfStream on the media source based on the state of the buffer or if appened segment was the final segment in the playlist.

##### Parameters:

Name | Type | Description
--- | --- | ---
`playlist` | Object | a media playlist object
`mediaSource` | Object | the MediaSource object
`segmentIndex` | Number | the index of segment we last appended

Source:
  - segment-loader.js, line 24

##### Returns:

do we need to call endOfStream on the MediaSource

Type
  Boolean

#### dispose()

dispose of the source updater and the underlying sourceBuffer

Source:
  - source-updater.js, line 166

#### dispose()

Destroys the stream and cleans up.

Source:
  - stream.js, line 84

#### dispose()

dispose of the SegmentLoader and reset to the default state

Source:
  - segment-loader.js, line 175

#### duration(duration)

Queue an update to set the duration.

##### Parameters:

Name | Type | Description
--- | --- | ---
`duration` | Double | what to set the duration to

Source:
  - source-updater.js, line 97
See:
  - http://www.w3.org/TR/media-source/#widl-MediaSource-duration

#### enableFunction(playlist, changePlaylistFn, enableopt) → {Boolean}

Enable/disable playlist function. It is intended to have the first two arguments partially-applied in order to create the final per-playlist function.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`playlist` | PlaylistLoader |  | The rendition or media-playlist
`changePlaylistFn` | function |  | A function to be called after a playlist's enabled-state has been changed. Will NOT be called if a playlist's enabled-state is unchanged
`enable` | Boolean | <optional> | Value to set the playlist enabled-state to or if undefined returns the current enabled-state for the playlist

Source:
  - rendition-mixin.js, line 15

##### Returns:

The current enabled-state of the playlist

Type
  Boolean

#### error(error) → {Error}

set an error on the segment loader and null out any pending segements

##### Parameters:

Name | Type | Description
--- | --- | ---
`error` | Error | the error to set on the SegmentLoader

Source:
  - segment-loader.js, line 226

##### Returns:

the error that was set or that is currently set

Type
  Error

#### findAdCue()

Searches for an ad cue that overlaps with the given mediaTime

Source:
  - ad-cue-tags.js, line 9

#### findGaps(buffered) → {TimeRanges}

Returns gaps within a list of TimeRanges

##### Parameters:

Name | Type | Description
--- | --- | ---
`buffered` | TimeRanges | the TimeRanges object

Source:
  - ranges.js, line 70

##### Returns:

a TimeRanges object of gaps

Type
  TimeRanges

#### findNextRange(timeRanges, time) → {TimeRanges}

Returns the TimeRanges that begin later than the specified time.

##### Parameters:

Name | Type | Description
--- | --- | ---
`timeRanges` | TimeRanges | the TimeRanges object to query
`time` | number | the time to filter on.

Source:
  - ranges.js, line 59

##### Returns:

a new TimeRanges object.

Type
  TimeRanges

#### findRange(buffered, time) → {TimeRanges}

Attempts to find the buffered TimeRange that contains the specified time.

##### Parameters:

Name | Type | Description
--- | --- | ---
`buffered` | TimeRanges | the TimeRanges object to query
`time` | number | the time to filter on.

Source:
  - ranges.js, line 46

##### Returns:

a new TimeRanges object

Type
  TimeRanges

#### findSoleUncommonTimeRangesEnd(original, update) → {Number|null}

Search for a likely end time for the segment that was just appened based on the state of the `buffered` property before and after the append. If we fin only one such uncommon end-point return it.

##### Parameters:

Name | Type | Description
--- | --- | ---
`original` | TimeRanges | the buffered time ranges before the update
`update` | TimeRanges | the buffered time ranges after the update

Source:
  - ranges.js, line 96

##### Returns:

the end time added between `original` and `update`, or null if one cannot be unambiguously determined.

Type
  Number | null

#### formatHexString(e, i)

format a number as hex string

##### Parameters:

Name | Type | Description
--- | --- | ---
`e` | Number | The number
`i` | Number | the iterator

Source:
  - bin-utils.js, line 21

#### forwardDuration(playlist, endSequence)

walk forward until we find a duration we can use or return a failure

##### Parameters:

Name | Type | Description
--- | --- | ---
`playlist` | Playlist | the playlist to walk through
`endSequence` | Number | the mediaSequence to stop walking on

Source:
  - playlist.js, line 69

#### getPlaylistSyncPoints(playlist) → {Object|Object.expiredSync|null|Object.segmentSync|null}

Returns an array with two sync points. The first being an expired sync point, which is the most recent segment with timing sync data that has fallen off the playlist. The second is a segment sync point, which is the first segment that has timing sync data in the current playlist.

##### Parameters:

Name | Type | Description
--- | --- | ---
`playlist` | Object | a media playlist object

Source:
  - playlist.js, line 222

##### Returns:

- an object containing the two sync points
  Type
    Object
- sync point data from an expired segment
  Type
    Object.expiredSync | null
- sync point data from a segment in the playlist
  Type
    Object.segmentSync | null

#### getSegmentBufferedPercent(startOfSegment, segmentDuration, currentTime, buffered) → {Number}

Return the amount of a range specified by the startOfSegment and segmentDuration overlaps the current buffered content.

##### Parameters:

Name | Type | Description
--- | --- | ---
`startOfSegment` | Number | the time where the segment begins
`segmentDuration` | Number | the duration of the segment in seconds
`currentTime` | Number | time in seconds where the current playback is at
`buffered` | TimeRanges | the state of the buffer

Source:
  - ranges.js, line 278

##### Returns:

percentage of the segment's time range that is already in `buffered`

Type
  Number

#### getSyncPoint(media, duration, currentTimeline) → {Object}

Find a sync-point for the playlist specified A sync-point is defined as a known mapping from display-time to a segment-index in the current playlist.

##### Parameters:

Name | Type | Description
--- | --- | ---
`media` | Playlist | The playlist that needs a sync-point
`duration` | Number | Duration of the MediaSource (Infinite if playing a live source)
`currentTimeline` | Number | The last timeline from which a segment was loaded

Source:
  - sync-controller.js, line 166

##### Returns:

- A sync-point object

Type
  Object

#### getSyncSegmentCandidate_(playlist) → {Number}

The segment loader has no recourse except to fetch a segment in the current playlist and use the internal timestamps in that segment to generate a syncPoint. This function returns a good candidate index for that process.

##### Parameters:

Name | Type | Description
--- | --- | ---
`playlist` | Object | the playlist object to look for a

Source:
  - segment-loader.js, line 644

##### Returns:

An index of a segment from the playlist to load

Type
  Number

#### handleDecrypted_(data)

Handles response from the decrypter and attaches the decrypted bytes to the pending segment

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Object | Response from decrypter

Source:
  - segment-loader.js, line 970

#### handleHlsLoadedMetadata(qualityLevels, hls)

Adds quality levels to list once playlist metadata is available

##### Parameters:

Name | Type | Description
--- | --- | ---
`qualityLevels` | QualityLevelList | The QualityLevelList to attach events to.
`hls` | Object | Hls object to listen to for media events.

Source:
  - videojs-contrib-hls.js, line 105

#### handleHlsMediaChange(qualityLevels, playlistLoader)

Updates the selectedIndex of the QualityLevelList when a mediachange happens in hls.

##### Parameters:

Name | Type | Description
--- | --- | ---
`qualityLevels` | QualityLevelList | The QualityLevelList to update.
`playlistLoader` | PlaylistLoader | PlaylistLoader containing the new media info.

Source:
  - videojs-contrib-hls.js, line 80

#### HlsSourceHandler()

The Source Handler object, which informs video.js what additional MIME types are supported and sets up playback. It is registered automatically to the appropriate tech based on the capabilities of the browser it is running in. It is not necessary to use or modify this object in normal usage.

Source:
  - videojs-contrib-hls.js, line 651

#### initSegmentId()

Returns a unique string identifier for a media initialization segment.

Source:
  - segment-loader.js, line 74

#### intervalDuration(playlist, endSequenceopt, expired) → {Number}

Calculate the media duration from the segments associated with a playlist. The duration of a subinterval of the available segments may be calculated by specifying an end index.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`playlist` | Object |  | a media playlist object
`endSequence` | Number | <optional> | an exclusive upper boundary for the playlist. Defaults to playlist length.
`expired` | Number |  | the amount of time that has dropped off the front of the playlist in a live scenario

Source:
  - playlist.js, line 112

##### Returns:

the duration between the first available segment and end index.

Type
  Number

#### isBlacklisted(playlist) → {boolean}

Check whether the playlist is blacklisted or not.

##### Parameters:

Name | Type | Description
--- | --- | ---
`playlist` | Object | the media playlist object

Source:
  - playlist.js, line 457

##### Returns:

whether the playlist is blacklisted or not

Type
  boolean

#### isEnabled(playlist) → {boolean}

Check whether the playlist is enabled or not.

##### Parameters:

Name | Type | Description
--- | --- | ---
`playlist` | Object | the media playlist object

Source:
  - playlist.js, line 468

##### Returns:

whether the playlist is enabled or not

Type
  boolean

#### load()

load a playlist and start to fill the buffer

Source:
  - segment-loader.js, line 238

#### mimeType(mimeType)

create/set the following mimetype on the SourceBuffer through a SourceUpdater

##### Parameters:

Name | Type | Description
--- | --- | ---
`mimeType` | String | the mime type string to use

Source:
  - segment-loader.js, line 387

#### objectChanged(a, b) → {Boolean}

determine if an object a is differnt from and object b. both only having one dimensional properties

##### Parameters:

Name | Type | Description
--- | --- | ---
`a` | Object | object one
`b` | Object | object two

Source:
  - master-playlist-controller.js, line 27

##### Returns:

if the object has changed or not

Type
  Boolean

#### off(type, listener) → {Boolean}

Remove a listener for a specified event type.

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | String | the event name
`listener` | function | a function previously registered for this type of event through `on`

Source:
  - stream.js, line 36

##### Returns:

if we could turn it off or not

Type
  Boolean

#### on(type, listener)

Add a listener for a specified event type.

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | String | the event name
`listener` | function | the callback to be invoked when an event of the specified type occurs

Source:
  - stream.js, line 21

#### pause()

Prevent the loader from fetching additional segments. If there is a segment request outstanding, it will finish processing before the loader halts. A segment loader can be unpaused by calling load().

Source:
  - segment-loader.js, line 364

#### paused()

Returns whether the segment loader is fetching additional segments when given the opportunity. This property can be modified through calls to pause() and load().

Source:
  - segment-loader.js, line 377

#### pipe(destination)

Forwards all `data` events on this stream to the destination stream. The destination stream should provide a method `push` to receive the data events as they arrive.

##### Parameters:

Name | Type | Description
--- | --- | ---
`destination` | Stream | the stream that will receive all `data` events

Source:
  - stream.js, line 95
See:
  - http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options

#### playlist(media)

set a playlist on the segment loader

##### Parameters:

Name | Type | Description
--- | --- | ---
`media` | PlaylistLoader | the playlist to set on the segment loader

Source:
  - segment-loader.js, line 286

#### printableRange(range) → {String}

Gets a human readable string for a TimeRange

##### Parameters:

Name | Type | Description
--- | --- | ---
`range` | TimeRange |

Source:
  - ranges.js, line 327

##### Returns:

a human readable string

Type
  String

#### probeSegmentInfo(segmentInfo)

Probe or inspect a fmp4 or an mpeg2-ts segment to determine the start and end of the segment in it's internal "media time". Used to generate mappings from that internal "media time" to the display time that is shown on the player.

##### Parameters:

Name | Type | Description
--- | --- | ---
`segmentInfo` | SegmentInfo | The current active request information

Source:
  - sync-controller.js, line 269

#### queueCallback_()

que a callback to run

Source:
  - source-updater.js, line 143

#### reloadSourceOnError(optionsopt)

Reload the source when an error is detected as long as there wasn't an error previously within the last 30 seconds

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`options` | Object | <optional> | an object with plugin options

Source:
  - reload-source-on-error.js, line 114

#### remove(start, end)

Queue an update to remove a time range from the buffer.

##### Parameters:

Name | Type | Description
--- | --- | ---
`start` | Number | where to start the removal
`end` | Number | where to end the removal

Source:
  - source-updater.js, line 110
See:
  - http://www.w3.org/TR/media-source/#widl-SourceBuffer-remove-void-double-start-unrestricted-double-end

#### remove(start, end)

Remove any data in the source buffer between start and end times

##### Parameters:

Name | Type | Description
--- | --- | ---
`start` | Number | the start time of the region to remove from the buffer
`end` | Number | the end time of the region to remove from the buffer

Source:
  - segment-loader.js, line 435

#### renditionSelectionMixin(hlsHandler)

A mixin function that adds the `representations` api to an instance of the HlsHandler class

##### Parameters:

Name | Type | Description
--- | --- | ---
`hlsHandler` | HlsHandler | An instance of HlsHandler to add the representation API into

Source:
  - rendition-mixin.js, line 87

#### reset()

Reset the state of the inspection cache when we do a rendition switch

Source:
  - sync-controller.js, line 257

#### resetEverything()

Delete all the buffered data and reset the SegmentLoader

Source:
  - segment-loader.js, line 405

#### resetLoader()

Force the SegmentLoader to resync and start loading around the currentTime instead of starting at the end of the buffer Useful for fast quality changes

Source:
  - segment-loader.js, line 416

#### resyncLoader()

Force the SegmentLoader to restart synchronization and make a conservative guess before returning to the simple walk-forward method

Source:
  - segment-loader.js, line 425

#### runCallback_()

run a queued callback

Source:
  - source-updater.js, line 151

#### safeGetComputedStyle(el, the)

Returns the CSS value for the specified property on an element using `getComputedStyle`. Firefox has a long-standing issue where getComputedStyle() may return null when running in an iframe with `display: none`.

##### Parameters:

Name | Type | Description
--- | --- | ---
`el` | HTMLElement | the htmlelement to work on
`the` | string | proprety to get the style for

Source:
  - videojs-contrib-hls.js, line 65
See:
  - https://bugzilla.mozilla.org/show_bug.cgi?id=548397

#### saveExpiredSegmentInfo(oldPlaylist, newPlaylist)

Save any meta-data present on the segments when segments leave the live window to the playlist to allow for synchronization at the playlist level later.

##### Parameters:

Name | Type | Description
--- | --- | ---
`oldPlaylist` | Playlist | The previous active playlist
`newPlaylist` | Playlist | The updated and most current playlist

Source:
  - sync-controller.js, line 219

#### segmentXhrHeaders()

Defines headers for use in the xhr request for a particular segment.

Source:
  - segment-loader.js, line 61

#### setDateTimeMapping(playlist)

Save the mapping from playlist's ProgramDateTime to display. This should only ever happen once at the start of playback.

##### Parameters:

Name | Type | Description
--- | --- | ---
`playlist` | Playlist | The currently active playlist

Source:
  - sync-controller.js, line 245

#### stableSort(array, sortFn)

Resuable stable sort function

##### Parameters:

Name | Type | Description
--- | --- | ---
`array` | Playlists |
`sortFn` | function | Different comparators

Source:
  - videojs-contrib-hls.js, line 119

#### textRange(range, i)

convert a TimeRange to text

##### Parameters:

Name | Type | Description
--- | --- | ---
`range` | TimeRange | the timerange to use for conversion
`i` | Number | the iterator on the range to convert

Source:
  - bin-utils.js, line 11

#### timestampOffset() → {Number}

Set/get the timestampoffset on the SourceBuffer

Source:
  - source-updater.js, line 130

##### Returns:

the timestamp offset

Type
  Number

#### trigger(type)

Trigger an event of the specified type on this stream. Any additional arguments to this function are passed as parameters to event listeners.

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | String | the event name

Source:
  - stream.js, line 53

#### updateMaster(master, media) → {Object}

Returns a new master playlist that is the result of merging an updated media playlist into the original version. If the updated media playlist does not match any of the playlist entries in the original master playlist, null is returned.

##### Parameters:

Name | Type | Description
--- | --- | ---
`master` | Object | a parsed master M3U8 object
`media` | Object | a parsed media M3U8 object

Source:
  - playlist-loader.js, line 56

##### Returns:

a new object that represents the original master playlist with the updated media playlist merged in, or null if the merge produced no change.

Type
  Object

#### updateSegments(original, update, offsetopt)

Returns a new array of segments that is the result of merging properties from an older list of segments onto an updated list. No properties on the updated playlist will be overridden.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`original` | Array |  | the outdated list of segments
`update` | Array |  | the updated list of segments
`offset` | Number | <optional> | the index of the first update segment in the original segment list. For non-live playlists, this should always be zero and does not need to be specified. For live playlists, it should be the difference between the media sequence numbers in the original and updated playlists.

Source:
  - playlist-loader.js, line 30

##### Returns:

a list of merged segment objects

#### updating() → {Boolean}

wether the underlying sourceBuffer is updating or not

Source:
  - source-updater.js, line 121

##### Returns:

the updating status of the SourceBuffer

Type
  Boolean