Class StreamManager

Handles dynamic ad insertion streams. This class manages interactions with DAI servers, handles tracking pings, and emits stream and ad events.
Constructors
constructor
Methods
addEventListener
Adds a listener for the given event type.
getStreamId
Returns the stream ID for the current stream.
loadStreamMetadata
Requests the DAI SDK to load ad metadata and emits a LOADED stream event.
removeEventListener
Removes a listener for the given StreamEvent event type.
replaceAdTagParameters
Replaces all of the ad tag parameters used for upcoming ad requests for a live stream.
requestStream
Requests a stream for IMA DAI to load using provided stream parameters.
reset
Resets the stream manager and removes any continuous polling.

Constructors


constructor

new StreamManager(mediaElement?: HTMLMediaElement): StreamManager
Parameters
Optional mediaElement: HTMLMediaElement The HTML media element where playback occurs. If you are using a custom player, you must provide this parameter.
Returns
StreamManager

Methods


addEventListener

addEventListener(type: Type, listener: ((event: StreamEvent) => void)): void
Adds a listener for the given event type.
Parameters
type: Type The stream event type.
listener: ((event: StreamEvent) => void) A callback function for the ad listener.

getStreamId

getStreamId(): string
Returns the stream ID for the current stream.
Returns
string

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.

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: {
  [key: string]: string;
}
The replacement ad tag parameters. Must have string values.

requestStream

requestStream(loadRequest: LoadRequestData, streamRequest: StreamRequest): Promise<LoadRequestData | ErrorData>
Requests a stream for IMA DAI to load using provided stream parameters.
Parameters
loadRequest: LoadRequestData an instance of the CAF LoadRequestData class that contains parameters to load the stream.
streamRequest: StreamRequest contains parameters to load the stream metadata.
Returns
Promise<LoadRequestData | ErrorData>

reset

reset(): void
Resets the stream manager and removes any continuous polling.