Class: shakaExtern

Types and interfaces which are used outside the library.

Source:

Type Definitions

AbrConfiguration

Type:
Properties:
Name Type Description
manager shakaExtern.AbrManager The AbrManager instance.
enabled boolean If true, enable adaptation by the current AbrManager. Defaults to true.
defaultBandwidthEstimate number The default bandwidth estimate to use if there is not enough data, in bit/sec.
Source:

AdvancedDrmConfiguration

Type:
  • {distinctiveIdentifierRequired: boolean, persistentStateRequired: boolean, videoRobustness: string, audioRobustness: string, serverCertificate: Uint8Array}
Properties:
Name Type Description
distinctiveIdentifierRequired boolean Defaults to false.
True if the application requires the key system to support distinctive identifiers.
persistentStateRequired boolean Defaults to false.
True if the application requires the key system to support persistent state, e.g., for persistent license storage.
videoRobustness string A key-system-specific string that specifies a required security level for video. Defaults to '', i.e., no specific robustness required.
audioRobustness string A key-system-specific string that specifies a required security level for audio. Defaults to '', i.e., no specific robustness required.
serverCertificate Uint8Array Defaults to null, i.e., certificate will be requested from the license server if required.
A key-system-specific server certificate used to encrypt license requests. Its use is optional and is meant as an optimization to avoid a round-trip to request a certificate.
Source:

CreateSegmentIndexFunction

Creates a SegmentIndex; returns a Promise that resolves after the SegmentIndex has been created.
Type:
  • function(): !Promise
Source:

DashContentProtectionCallback

Type:
Source:
See:

DashManifestConfiguration

Type:
Properties:
Name Type Description
customScheme shakaExtern.DashContentProtectionCallback If given, invoked by a DASH manifest parser to interpret custom or non-standard DRM schemes found in the manifest. The argument is a ContentProtection node. Return null if not recognized.
clockSyncUri string A default clock sync URI to be used with live streams which do not contain any clock sync information. The "Date" header from this URI will be used to determine the current time.
Source:

DrmConfiguration

Type:
Properties:
Name Type Description
retryParameters shakaExtern.RetryParameters Retry parameters for license requests.
servers Object.<string, string> Required for all but the clear key CDM.
A dictionary which maps key system IDs to their license servers. For example, {'com.widevine.alpha': 'http://example.com/drm'}.
clearKeys Object.<string, string> Forces the use of the Clear Key CDM. A map of key IDs (hex) to keys (hex).
advanced Object.<string, shakaExtern.AdvancedDrmConfiguration> Optional.
A dictionary which maps key system IDs to advanced DRM configuration for those key systems.
Source:

DrmInfo

DRM configuration for a single key system.
Type:
  • {keySystem: string, licenseServerUri: string, distinctiveIdentifierRequired: boolean, persistentStateRequired: boolean, audioRobustness: string, videoRobustness: string, serverCertificate: Uint8Array, initData: Array.<!shakaExtern.InitDataOverride>}
Properties:
Name Type Description
keySystem string Required.
The key system, e.g., "com.widevine.alpha".
licenseServerUri string Filled in by DRM config if missing.
The license server URI.
distinctiveIdentifierRequired boolean Defaults to false. Can be filled in by advanced DRM config.
True if the application requires the key system to support distinctive identifiers.
persistentStateRequired boolean Defaults to false. Can be filled in by advanced DRM config.
True if the application requires the key system to support persistent state, e.g., for persistent license storage.
audioRobustness string Defaults to '', e.g., no specific robustness required. Can be filled in by advanced DRM config.
A key-system-specific string that specifies a required security level.
videoRobustness string Defaults to '', e.g., no specific robustness required. Can be filled in by advanced DRM config.
A key-system-specific string that specifies a required security level.
serverCertificate Uint8Array Defaults to null, e.g., certificate will be requested from the license server if required. Can be filled in by advanced DRM config.
A key-system-specific server certificate used to encrypt license requests. Its use is optional and is meant as an optimization to avoid a round-trip to request a certificate.
initData Array.<!shakaExtern.InitDataOverride> Defaults to [], e.g., no override.
A list of initialization data which override any initialization data found in the content. See also shakaExtern.InitDataOverride.
Source:

DrmSupportType

Type:
  • {persistentState: boolean}
Properties:
Name Type Description
persistentState boolean Whether this key system supports persistent state.
Source:

FindSegmentPositionFunction

Finds the position of the segment for the given time, in seconds, relative to the start of a particular Period; returns null if the position of the segment could not be determined. Note: the position of a segment is unique only among segments within the same Period.
Type:
  • function(number): ?number
Source:

GetSegmentReferenceFunction

Gets the SegmentReference for the segment at the given position; returns null if no such SegmentReference exists. Note: the position of a segment is unique only among segments within the same Period.
Type:
Source:

InitDataOverride

Explicit initialization data, which override any initialization data in the content. The initDataType values and the formats that they correspond to are specified here.
Type:
  • {initData: !Uint8Array, initDataType: string}
Properties:
Name Type Description
initData Uint8Array Initialization data in the format indicated by initDataType.
initDataType string A string to indicate what format initData is in.
Source:

Manifest

A Manifest object describes a collection of streams (segmented audio, video, or text data) that share a common timeline. We call the collection of streams "the presentation" and their timeline "the presentation timeline". A Manifest describes one of two types of presentations: live and video-on-demand.

A live presentation begins at some point in time and either continues indefinitely or ends when the presentation stops broadcasting. For a live presentation, wall-clock time maps onto the presentation timeline, and the current wall-clock time maps to the live-edge (AKA "the current presentation time"). In contrast, a video-on-demand presentation exists entirely independent of wall-clock time.

The presentation timeline is divided into one or more Periods, and each of these Periods contains its own collection of streams. Periods group their streams by type (e.g., 'audio', 'video', or 'text') and logical content, and each individual group defines a StreamSet.

A stream has the same logical content as another stream if the only difference between the two is their quality. For example, an SD video stream and an HD video stream that depict the same scene have the same logical content; whereas an English audio stream and a French audio stream have different logical content. The player can automatically switch between streams which have the same logical content to adapt to network conditions.

Type:
Properties:
Name Type Description
presentationTimeline shaka.media.PresentationTimeline Required.
The presentation timeline.
periods Array.<!shakaExtern.Period> Required.
The presentation's Periods. There must be at least one Period.
offlineSessionIds Array.<string> Defaults to [].
An array of EME sessions to load for offline playback.
minBufferTime number Defaults to 0.
The minimum number of seconds of content that must be buffered before playback can begin. Can be overridden by a higher value from the Player configuration.
Source:

ManifestConfiguration

Type:
Properties:
Name Type Description
retryParameters shakaExtern.RetryParameters Retry parameters for manifest requests.
dash shakaExtern.DashManifestConfiguration Advanced parameters used by the DASH manifest parser.
Source:

ManifestDB

Type:
  • {key: number, originalManifestUri: string, duration: number, size: number, periods: !Array.<shakaExtern.PeriodDB>, sessionIds: !Array.<string>, drmInfo: ?shakaExtern.DrmInfo, appMetadata: Object}
Properties:
Name Type Attributes Description
key number The key that uniquely identifies the manifest.
originalManifestUri string The URI that the manifest was originally loaded from.
duration number The total duration of the media, in seconds.
size number The total size of all stored segments, in bytes.
periods Array.<shakaExtern.PeriodDB> The Periods that are stored.
sessionIds Array.<string> The DRM offline session IDs for the media.
drmInfo shakaExtern.DrmInfo <nullable>
The DRM info used to initialize EME.
appMetadata Object A metadata object passed from the application.
Source:

OfflineConfiguration

Type:
Properties:
Name Type Description
trackSelectionCallback function(!Array.<shakaExtern.Track>): !Array.<shakaExtern.Track> Called inside store() to determine which tracks to save from a manifest. It is passed an array of Tracks from the manifest and it should return an array of the tracks to store. This is called for each Period in the manifest (in order).
progressCallback function(shakaExtern.StoredContent, number) Called inside store() to give progress info back to the app. It is given the current manifest being stored and the progress of it being stored.
Source:

OfflineSupport

Type:
  • {basic: boolean, encrypted: !Object.<string, boolean>}
Properties:
Name Type Description
basic boolean True if offline is usable at all.
encrypted Object.<string, boolean> A map of key system name to whether it supports offline playback.
Source:

Period

A Period object contains the Streams for part of the presentation.
Type:
Properties:
Name Type Description
startTime number Required.
The Period's start time, in seconds, relative to the start of the presentation. The first Period must begin at the start of the presentation. The Period ends immediately before the next Period's start time or exactly at the end of the presentation timeline. Periods which begin after the end of the presentation timeline are ignored.
streamSets Array.<shakaExtern.StreamSet> Required.
The Period's StreamSets. There must be at least one StreamSet.
Source:

PeriodDB

Type:
Properties:
Name Type Description
startTime number The start time of the period, in seconds.
streams Array.<shakaExtern.StreamDB> The streams that define the Period.
Source:

PlayerConfiguration

Type:
Properties:
Name Type Description
drm shakaExtern.DrmConfiguration DRM configuration and settings.
manifest shakaExtern.ManifestConfiguration Manifest configuration and settings.
streaming shakaExtern.StreamingConfiguration Streaming configuration and settings.
abr shakaExtern.AbrConfiguration ABR configuration and settings.
preferredAudioLanguage string The preferred language to use for audio tracks. If not given it will use the 'main' track. Changing this during playback will cause the language selection algorithm to run again, and may change the active audio track.
preferredTextLanguage string The preferred language to use for text tracks. If a matching text track is found, and the selected audio and text tracks have different languages, the text track will be shown. Changing this during playback will cause the language selection algorithm to run again, and may change the active text track.
restrictions shakaExtern.Restrictions The application restrictions to apply to the tracks. The track must meet all the restrictions to be playable.
Source:

Request

Defines a network request. This is passed to one or more request filters that may alter the request, then it is passed to a scheme plugin which performs the actual operation.
Type:
  • {uris: !Array.<string>, method: string, body: ArrayBuffer, headers: !Object.<string, string>, allowCrossSiteCredentials: boolean, retryParameters: !shakaExtern.RetryParameters}
Properties:
Name Type Description
uris Array.<string> An array of URIs to attempt. They will be tried in the order they are given.
method string The HTTP method to use for the request.
body ArrayBuffer The body of the request.
headers Object.<string, string> A mapping of headers for the request. e.g.: {'HEADER': 'VALUE'}
allowCrossSiteCredentials boolean Make requests with credentials. This will allow cookies in cross-site requests. See http://goo.gl/YBRKPe.
retryParameters shakaExtern.RetryParameters An object used to define how often to make retries.
Source:

Response

Defines a response object. This includes the response data and header info. This is given back from the scheme plugin. This is passed to a response filter before being returned from the request call.
Type:
  • {uri: string, data: ArrayBuffer, headers: !Object.<string, string>}
Properties:
Name Type Description
uri string The URI which was loaded. Request filters and server redirects can cause this to be different from the original request URIs.
data ArrayBuffer The body of the response.
headers Object.<string, string> A map of response headers, if supported by the underlying protocol. All keys should be lowercased. For HTTP/HTTPS, may not be available cross-origin.
Source:

Restrictions

An object describing application restrictions on what tracks can play. All restrictions must be fulfilled for a track to be playable. If a track does not meet the restrictions, it will not appear in the track list and it will not be played.
Type:
  • {minWidth: number, maxWidth: number, minHeight: number, maxHeight: number, minPixels: number, maxPixels: number, minAudioBandwidth: number, maxAudioBandwidth: number, minVideoBandwidth: number, maxVideoBandwidth: number}
Properties:
Name Type Description
minWidth number The minimum width of a video track, in pixels.
maxWidth number The maximum width of a video track, in pixels.
minHeight number The minimum height of a video track, in pixels.
maxHeight number The maximum height of a video track, in pixels.
minPixels number The minimum number of total pixels in a video track (i.e. width * height).
maxPixels number The maximum number of total pixels in a video track (i.e. width * height).
minAudioBandwidth number The minimum bandwidth of an audio track, in bit/sec.
maxAudioBandwidth number The maximum bandwidth of an audio track, in bit/sec.
minVideoBandwidth number The minimum bandwidth of a video track, in bit/sec.
maxVideoBandwidth number The maximum bandwidth of a video track, in bit/sec.
Source:

RetryParameters

Parameters for retrying requests.
Type:
  • {maxAttempts: number, baseDelay: number, backoffFactor: number, fuzzFactor: number, timeout: number}
Properties:
Name Type Description
maxAttempts number The maximum number of times the request should be attempted.
baseDelay number The delay before the first retry, in milliseconds.
backoffFactor number The multiplier for successive retry delays.
fuzzFactor number The maximum amount of fuzz to apply to each retry delay. For example, 0.5 means "between 50% below and 50% above the retry delay."
timeout number The request timeout, in milliseconds. Zero means "unlimited".
Source:

SegmentDataDB

Type:
  • {key: number, data: !ArrayBuffer, manifestKey: number, streamNumber: number, segmentNumber: number}
Properties:
Name Type Description
key number A key that uniquely describes the segment.
data ArrayBuffer The data contents of the segment.
manifestKey number The key of the manifest this belongs to.
streamNumber number The index of the stream this belongs to.
segmentNumber number The index of the segment within the stream.
Source:

SegmentDB

Type:
  • {startTime: number, endTime: number, uri: string}
Properties:
Name Type Description
startTime number The start time of the segment, in seconds from the start of the Period.
endTime number The end time of the segment, in seconds from the start of the Period.
uri string The offline URI where the segment is found.
Source:

Stats

Contains statistics and information about the current state of the player. This is meant for applications that want to log quality-of-experience (QoE) or other stats. These values will reset when load() is called again.
Type:
  • {width: number, height: number, streamBandwidth: number, decodedFrames: number, droppedFrames: number, estimatedBandwidth: number, playTime: number, bufferingTime: number, switchHistory: !Array.<shakaExtern.StreamChoice>}
Properties:
Name Type Description
width number The width of the current video track.
height number The height of the current video track.
streamBandwidth number The bandwidth required for the current streams (total, in bit/sec).
decodedFrames number The total number of frames decoded by the Player. This may be NaN if this is not supported by the browser.
droppedFrames number The total number of frames dropped by the Player. This may be NaN if this is not supported by the browser.
estimatedBandwidth number The current estimated network bandwidth (in bit/sec).
playTime number The total time spent in a playing state in seconds.
bufferingTime number The total time spent in a buffering state in seconds.
switchHistory Array.<shakaExtern.StreamChoice> A history of the stream changes.
Source:

StoredContent

Type:
  • {offlineUri: string, originalManifestUri: string, duration: number, size: number, tracks: !Array.<shakaExtern.Track>, appMetadata: Object}
Properties:
Name Type Description
offlineUri string An offline URI to access the content. This can be passed directly to Player.
originalManifestUri string The original manifest URI of the content stored.
duration number The duration of the content, in seconds.
size number The size of the content, in bytes.
tracks Array.<shakaExtern.Track> The tracks that are stored. This only lists those found in the first Period.
appMetadata Object The metadata passed to store().
Source:

Stream

A Stream object describes a single stream (segmented media data).
Type:
Properties:
Name Type Attributes Description
id number Required.
A unique ID among all Stream objects within the same Manifest.
createSegmentIndex shakaExtern.CreateSegmentIndexFunction Required.
Creates the Stream's SegmentIndex (asynchronously).
findSegmentPosition shakaExtern.FindSegmentPositionFunction Required.
Finds the position of the segment for the given time. The caller must call createSegmentIndex() and wait until the returned Promise resolves before calling this function.
getSegmentReference shakaExtern.GetSegmentReferenceFunction Required.
Gets the SegmentReference for the segment at the given position. The caller must call createSegmentIndex() and wait until the returned Promise resolves before calling this function.
initSegmentReference shaka.media.InitSegmentReference The Stream's initialization segment metadata, or null if the segments are self-initializing.
presentationTimeOffset number | undefined Defaults to 0.
The amount of time, in seconds, that the stream's presentation timestamps are offset from the start of the Stream's Period, i.e., this value should equal the first presentation timestamp of the first frame/sample in the period.

For example, for MP4 based streams, this value should equal the first segment's tfdt box's 'baseMediaDecodeTime' field (after it has been converted to seconds).
mimeType string Required.
The Stream's MIME type, e.g., 'audio/mp4', 'video/webm', or 'text/vtt'.
codecs string Defaults to '' (i.e., unknown / not needed).
The Stream's codecs, e.g., 'avc1.4d4015' or 'vp9', which must be compatible with the Stream's MIME type.
See https://tools.ietf.org/html/rfc6381
bandwidth number | undefined Audio and video streams only.
The stream's required bandwidth in bits per second.
width number | undefined Video streams only.
The stream's width in pixels.
height number | undefined Video streams only.
The stream's height in pixels.
kind string | undefined Text streams only.
The kind of text stream. For example, 'captions' or 'subtitles'.
encrypted boolean Defaults to false.
True if the stream is encrypted.
keyId string <nullable>
Defaults to null (i.e., unencrypted or key ID unknown).
The stream's key ID as a lowercase hex string. This key ID identifies the encryption key that the browser (key system) can use to decrypt the stream.
language string The Stream's language, specified as a language code.
Must be identical to the language of the containing StreamSet.
allowedByApplication boolean Defaults to true.
Set by the Player to indicate whether the stream is allowed to be played by the application.
allowedByKeySystem boolean Defaults to true.
Set by the Player to indicate whether the stream is allowed to be played by the key system.
Source:
See:

StreamChoice

Type:
  • {timestamp: number, id: number, type: string, fromAdaptation: boolean}
Properties:
Name Type Description
timestamp number The timestamp the choice was made, in seconds since 1970 (i.e. Date.now() / 1000).
id number The id of the stream that was chosen.
type string The type of stream chosen ('audio', 'text', or 'video')
fromAdaptation boolean True if the choice was made by AbrManager for adaptation; false if it was made by the application through selectTrack.
Source:

StreamDB

Type:
  • {id: number, primary: boolean, presentationTimeOffset: number, contentType: string, mimeType: string, codecs: string, kind: (string|undefined), language: string, width: ?number, height: ?number, initSegmentUri: ?string, encrypted: boolean, keyId: ?string, segments: !Array.<shakaExtern.SegmentDB>}
Properties:
Name Type Attributes Description
id number The unique id of the stream.
primary boolean Whether the stream set was primary.
presentationTimeOffset number The presentation time offset of the stream.
contentType string The type of the stream, 'audio', 'text', or 'video'.
mimeType string The MIME type of the stream.
codecs string The codecs of the stream.
kind string | undefined The kind of text stream; undefined for audio/video.
language string The language of the stream; '' for video.
width number <nullable>
The width of the stream; null for audio/text.
height number <nullable>
The height of the stream; null for audio/text.
initSegmentUri string <nullable>
The offline URI where the init segment is found; null if no init segment.
encrypted boolean Whether this stream is encrypted.
keyId string <nullable>
The key ID this stream is encrypted with.
segments Array.<shakaExtern.SegmentDB> An array of segments that make up the stream
Source:

StreamingConfiguration

The StreamingEngine's configuration options.
Type:
  • {retryParameters: shakaExtern.RetryParameters, rebufferingGoal: number, bufferingGoal: number, bufferBehind: number, ignoreTextStreamFailures: boolean}
Properties:
Name Type Description
retryParameters shakaExtern.RetryParameters Retry parameters for segment requests.
rebufferingGoal number The minimum number of seconds of content that the StreamingEngine must buffer before it can begin playback or can continue playback after it has entered into a buffering state (i.e., after it has depleted one more more of its buffers).
bufferingGoal number The number of seconds of content that the StreamingEngine will attempt to buffer ahead of the playhead. This value must be greater than or equal to the rebuffering goal.
bufferBehind number The maximum number of seconds of content that the StreamingEngine will keep in buffer behind the playhead when it appends a new media segment. The StreamingEngine will evict content to meet this limit.
ignoreTextStreamFailures boolean If true, the player will ignore text stream failures and proceed to play other streams.
Source:

StreamSet

A StreamSet object contains a set of Streams which have the same type, container/format, and logical content. A StreamSet's type and container/format define its MIME type.
Type:
Properties:
Name Type Description
language string Defaults to '' (i.e., unknown).
The Streams' language, specified as a language code.
See https://tools.ietf.org/html/rfc5646
See http://www.iso.org/iso/home/standards/language_codes.htm
type string Required.
The Streams' type, e.g., 'audio', 'video', or 'text'.
primary boolean Defaults to false.
True indicates that the player should use this StreamSet over others of the same type in the same Period. However, the player may use another StreamSet to meet application preferences, or to achieve better MIME type or DRM compatibility among other StreamSets.
drmInfos Array.<!shakaExtern.DrmInfo> Defaults to [] (i.e., no DRM).
An array of DrmInfo objects which describe DRM schemes are compatible with the content.
streams Array.<!shakaExtern.Stream> Required.
The StreamSets's Streams. There must be at least one Stream.
Source:

SupportType

An object detailing browser support for various features.
Type:
Properties:
Name Type Description
manifest Object.<string, boolean> A map of supported manifest types. The keys are manifest MIME types and file extensions.
media Object.<string, boolean> A map of supported media types. The keys are media MIME types.
drm Object.<string, ?shakaExtern.DrmSupportType> A map of supported key systems. The keys are the key system names. The value is null if it is not supported. Key systems not probed will not be in this dictionary.
Source:

Track

An object describing a media track. This object should be treated as read-only as changing any values does not have any effect. This is the public view of the Stream type.
Type:
  • {id: number, active: boolean, type: string, bandwidth: number, language: string, kind: ?string, width: ?number, height: ?number}
Properties:
Name Type Attributes Description
id number The unique ID of the track.
active boolean If true, this is the track is being streamed (another track may be visible/audible in the buffer).
type string The type of track, one of 'audio', 'text', or 'video'.
bandwidth number The bandwidth required to play the track, in bits/sec.
language string The language of the track, or '' for video tracks. This is the exact value provided in the manifest; it may need to be normalized.
kind string <nullable>
(only for text tracks) The kind of text track, either 'captions' or 'subtitles'.
width number <nullable>
(only for video tracks) The width of the track in pixels.
height number <nullable>
(only for video tracks) The height of the track in pixels.
Source: