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:
(constant) getMediaIndexForTime_
Determine the index of the segment that contains a specified
playback position in a media playlist.
- Source:
(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:
(constant) utils
utils to help dump binary data to the console
- Source:
Methods
abort()
abort anything that is currently doing on with the SegmentLoader
and reset to a default state
- Source:
abort(done)
Aborts the current segment and resets the segment parser.
Parameters:
Name | Type | Description |
---|---|---|
done |
function | function to call when done |
- Source:
- See:
addLoader(mediaGroup, uri)
add a PlaylistLoader given a mediaGroup, and a uri. for a combined track
we store null for the playlistloader
Parameters:
Name | Type | Default | Description |
---|---|---|---|
mediaGroup |
String | the mediaGroup to get the loader for | |
uri |
String | null | the uri to get the audio track/mediaGroup from |
- Source:
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:
- See:
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:
buffered()
Indicates what TimeRanges are buffered in the managed SourceBuffer.
- Source:
- See:
bufferIntersection(bufferA, bufferB) → {TimeRanges}
Calculate the intersection of two TimeRanges
Parameters:
Name | Type | Description |
---|---|---|
bufferA |
TimeRanges | |
bufferB |
TimeRanges |
Returns:
The interesection of `bufferA` with `bufferB`
- Type
- TimeRanges
byterangeStr()
Turns segment byterange into a string suitable for use in
HTTP Range requests
- Source:
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 |
Returns:
percent of the segment currently buffered
- Type
- Number
checkBuffer_(buffered, playlist, currentTime, hasPlayed, expired, timeCorrection) → {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 |
currentTime |
Number | the playback position in seconds |
hasPlayed |
Boolean | if the player has played before |
expired |
Number | the seconds expired off the playlist |
timeCorrection |
Number | correction value to add to current time when when determining media index to use |
- Source:
Returns:
a segment info object that describes the
request that should be made or null if no request is necessary
- 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 |
Returns:
- Type
- Number
clearBuffer()
clear anything that is currently in the buffer and throw it away
- Source:
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:
Returns:
do we need to call endOfStream on the MediaSource
- Type
- Boolean
dispose()
Dispose of this audio track and
the playlist loader that it holds inside
- Source:
dispose()
dispose of the source updater and the underlying sourceBuffer
- Source:
dispose()
Destroys the stream and cleans up.
dispose()
dispose of the SegmentLoader and reset to the default state
- Source:
duration(duration)
Queue an update to set the duration.
Parameters:
Name | Type | Description |
---|---|---|
duration |
Double | what to set the duration to |
- Source:
- See:
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:
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:
Returns:
the error that was set or that is currently set
- Type
- Error
expired(expired)
setter for expired time on the SegmentLoader
Parameters:
Name | Type | Description |
---|---|---|
expired |
Number | the exired time to set |
- Source:
findAdCue()
Searches for an ad cue that overlaps with the given mediaTime
- Source:
findGaps(buffered) → {TimeRanges}
Returns gaps within a list of TimeRanges
Parameters:
Name | Type | Description |
---|---|---|
buffered |
TimeRanges | the TimeRanges object |
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. |
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. |
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 |
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:
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:
getLoader(mediaGroup) → {PlaylistLoader|Null}
get a PlaylistLoader from this track given a mediaGroup name
Parameters:
Name | Type | Description |
---|---|---|
mediaGroup |
String | the mediaGroup to get the loader for |
- Source:
Returns:
the PlaylistLoader or null
- Type
- PlaylistLoader | 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 |
Returns:
percentage of the segment's time range that is
already in `buffered`
- Type
- Number
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:
init_()
Once all the starting parameters have been specified, begin
operation. This method should only be invoked from the INIT
state.
- Source:
initSegmentId()
Returns a unique string identifier for a media initialization
segment.
- Source:
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:
Returns:
the duration between the first available segment
and end index.
- Type
- Number
load()
load a playlist and start to fill the buffer
- Source:
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:
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:
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` |
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 |
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:
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:
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:
- See:
playlist(media)
set a playlist on the segment loader
Parameters:
Name | Type | Description |
---|---|---|
media |
PlaylistLoader | the playlist to set on the segment loader |
- Source:
queueCallback_()
que a callback to run
- Source:
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:
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:
- See:
removeLoader(mediaGroup)
remove a playlist loader from a track given the mediaGroup
Parameters:
Name | Type | Description |
---|---|---|
mediaGroup |
String | the mediaGroup to remove |
- Source:
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:
runCallback_()
run a queued callback
- Source:
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 |
segmentXhrHeaders()
Defines headers for use in the xhr request for a particular segment.
- Source:
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:
timestampOffset() → {Number}
Set/get the timestampoffset on the SourceBuffer
- Source:
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 |
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:
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
updateSegmentMetadata(playlist, segmentIndex, segmentEnd)
Updates segment with information about its end-point in time and, optionally,
the segment duration if we have enough information to determine a segment duration
accurately.
Parameters:
Name | Type | Description |
---|---|---|
playlist |
Object | a media playlist object |
segmentIndex |
Number | the index of segment we last appended |
segmentEnd |
Number | the known of the segment referenced by segmentIndex |
- Source:
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:
Returns:
a list of merged segment objects
updating() → {Boolean}
wether the underlying sourceBuffer is updating or not
- Source:
Returns:
the updating status of the SourceBuffer
- Type
- Boolean