Handles dynamic ad insertion streams. This class manages interactions with DAI servers,
handles tracking pings, and emits stream and ad events.
| Constructors | |
|---|---|
constructor
|
|
| Methods | |
|---|---|
add
|
Adds a listener for the given event type. |
content
|
Returns the content time without ads for a given stream time. |
focus
|
Puts the focus on the skip button, if present. |
get
|
Returns a
true value if the user can skip the current ad. |
load
|
Requests the DAI SDK to load ad metadata and emits a
LOADED stream
event.
|
on
|
Passes in a dictionary of processed metadata. |
previous
|
Returns the previous cuepoint for the given stream time. |
process
|
Processes timed metadata for streams. |
remove
|
Removes a listener for the given
StreamEvent
event type.
|
replace
|
Replaces all of the ad tag parameters used for upcoming ad requests for a live
stream.
|
request
|
Requests a stream for IMA DAI to load using provided stream parameters.
|
reset
|
Resets the stream manager and removes any continuous polling. |
stream
|
Returns the total stream time with ads for a given content time. |
Constructors
constructor
new StreamManager(videoElement: HTMLVideoElement, adUiElement?: HTMLElement, uiSettings?: UiSettings): StreamManager
| Parameters | |
|---|---|
videoElement: HTMLVideoElement
|
The HTML video element where playback occurs. |
|
The element where the ad UI renders. |
|
The UI settings to use for this stream. |
| Returns | |
|---|---|
StreamManager
|
|
Methods
addEventListener
addEventListener(type: Type | Type[], listener: ((event: StreamEvent) => void)): void
Adds a listener for the given event type.
| Parameters | |
|---|---|
type:
Type | Type[]
|
The ad event type or an array of event types. |
listener: ((event: StreamEvent) => void)
|
A callback function for the ad listener. |
contentTimeForStreamTime
contentTimeForStreamTime(streamTime: number): number
Returns the content time without ads for a given stream time. Returns the given stream
time for live streams.
| Parameters | |
|---|---|
streamTime: number
|
the stream time in seconds, combining content and ads. |
| Returns | |
|---|---|
number
|
the content time for the given stream time, not including ads. |
focus
focus(): void
Puts the focus on the skip button, if present. If not present, focus is put back on
the interactive element.
getAdSkippableState
getAdSkippableState(): boolean
Returns a
true value if the user can skip the current ad. When this value
changes, the StreamManager class emits a
SKIPPABLE_STATE_CHANGED stream event.
| Returns | |
|---|---|
boolean
|
true if the user can skip the current ad,
false otherwise.
|
loadStreamMetadata
loadStreamMetadata(): void
Requests the DAI SDK to load ad metadata and emits a
LOADED stream event.
Manually call this method when you retrieve the stream manifest from your third party
video stitcher. This method is only for Pod Serving VOD streams with third party video
stitcher.
onTimedMetadata
onTimedMetadata(metadata: {
[key: string]: string;
}): void
Passes in a dictionary of processed metadata. The dictionary expects the exact key
"TXXX" with the user-defined metadata string as the value. If your player
provides raw metadata, call the
StreamManager.processMetadata
method instead.
| Parameters | |
|---|---|
metadata: {
|
The dictionary of metadata. |
previousCuePointForStreamTime
previousCuePointForStreamTime(streamTime: number): CuePoint
Returns the previous cuepoint for the given stream time. If no previous cuepoint
exists, returns
null. Use this method to implement features like snapback
by calling the method when the user seeks to return the user to an ad break.
| Parameters | |
|---|---|
streamTime: number
|
the stream time that the user seeks to. |
| Returns | |
|---|---|
CuePoint
|
the previous cuepoint for the given stream time. |
processMetadata
processMetadata(type: string, data: string | Uint8Array, timestamp: number): void
Processes timed metadata for streams. Use this method if your video player provides
unparsed metadata with timestamps. Otherwise, call
StreamManager.onTimedMetadata.
| Parameters | |
|---|---|
type: string
|
Type for metadata. Must be the 'ID3' string for HLS, or the event
message scheme ID URI for DASH.
|
data: string | Uint8Array
|
Raw tag data. For ID3, must be the entire raw tag data. For DASH event messages, this is the message data string. |
timestamp: number
|
Time in seconds when to process data. For DASH, this parameter is the event message start time. |
removeEventListener
removeEventListener(type: Type, listener: ((event: StreamEvent) => void)): void
Removes a listener for the given
StreamEvent
event type. To successfully remove a listener, the listener parameter you pass to this
method must be equal by reference to the one previously passed to the
addEventListener method.
| Parameters | |
|---|---|
type:
Type
|
The type of event for which to remove the listener. |
listener: ((event: StreamEvent) => void)
|
The function to remove as a listener. |
replaceAdTagParameters
replaceAdTagParameters(adTagParameters: {
[key:
string]: string;
}): void
Replaces all of the ad tag parameters used for upcoming ad requests for a live stream.
| Parameters | |
|---|---|
adTagParameters: {
|
The replacement ad tag parameters. Must have string values. |
requestStream
requestStream(streamRequest: StreamRequest): void
Requests a stream for IMA DAI to load using provided stream parameters.
| Parameters | |
|---|---|
streamRequest:
StreamRequest
|
contains parameters to load the stream metadata. |
reset
reset(): void
Resets the stream manager and removes any continuous polling.
streamTimeForContentTime
streamTimeForContentTime(contentTime: number): number
Returns the total stream time with ads for a given content time. Returns the given
content time for live streams.
| Parameters | |
|---|---|
contentTime: number
|
the content time without any ads in seconds. |
| Returns | |
|---|---|
number
|
the total stream time that corresponds with the given content time after DAI inserts ads. |