# [ima](https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/roku/reference/ima).StreamManager

class static

## Constructor

### StreamManager

new
StreamManager()

Object for managing stream playback.

## Methods

### addEventListener

static

addEventListener(event, callback)

Adds a listener for the specified event. See the AdEvents constant for
supported events.

| #### Parameter ||
|---|---|
| event | string |
| callback | function() |

### createStreamManager

static

createStreamManager(streamRequest, streamInitResponse) returns [ima.StreamManager](https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/roku/reference/ima.StreamManager)

| #### Parameter ||
|---|---|
| streamRequest | [ima.StreamRequest](https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/roku/reference/ima.StreamRequest) |
| streamInitResponse | ima.StreamInitResponse |

Returns

:   `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/roku/reference/ima.StreamManager`

### destroy

static

destroy()

Destroys the stream manager, releases all resources, and removes any ad UI.

### enableInteractiveAds

static

enableInteractiveAds()

Unsupported. Instead pass data from the companion ad to RAF directly.
This is now a no op.

### getContentTime

static

getContentTime(streamTime) returns Integer

Gets a time in milliseconds for a VOD stream, representing the time in
the content without ads.
For more details, see the
[FAQ](https://developers.google.com/developers.google.com/ad-manager/dynamic-ad-insertion/sdk/roku/faq).
To get the content time for the current stream time pass in `-1`.

| #### Parameter ||
|---|---|
| streamTime | Integer The time in the stream. |

Returns

:   `Integer` The content time corresponding to the given stream time.

### getCuePoints

static

getCuePoints() returns Object

Returns all cue points corresponding to all ad breaks. This is only
valid for video on demand content where all ad breaks are known ahead
of time. All times represent the stream time in seconds.
For Cloud Stitching API streams, the `hasPlayed` property of each `ima.CuePoint` is always false.

Returns

:   `Object` An array with all cue points.

### getPreviousCuePoint

static

getPreviousCuePoint(time) returns [ima.CuePoint](https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/roku/reference/ima.CuePoint)

Returns the cue point preceding this time. The cue point indicates an ad
break. All times represent the stream time in seconds.

| #### Parameter ||
|---|---|
| time | Float The time to look up, `-1` indicates current time, and returns `Invalid` for all other streams. |

Returns

:   `https://developers.google.com/ad-manager/dynamic-ad-insertion/sdk/roku/reference/ima.CuePoint` An object with start, end, and hasPlayed. Returns
    Invalid if no cue point is available.

### getStreamTime

static

getStreamTime(contentTime) returns Integer

Gets time for the stream from a content time for VOD in milliseconds.
For more details, see the
[FAQ](https://developers.google.com/developers.google.com/ad-manager/dynamic-ad-insertion/sdk/roku/faq).

| #### Parameter ||
|---|---|
| contentTime | Integer The time of the content. |

Returns

:   `Integer` The stream time corresponding to the given content time.

### loadThirdPartyStream

static

loadThirdPartyStream(streamManifest, streamSubtitle)

Loads the ad metadata and calls the `loadUrl` function with the
provided `streamManifestUrl` and `streamSubtitle`
data. This function only works when the stream request type is
`ima.StreamType.POD_VOD`.

| #### Parameter ||
|---|---|
| streamManifest | string The stream manifest URL with ads stitched. |
| streamSubtitle | (Array of Array of T or Invalid) The subtitles associate with the stream, or `Invalid` if none. |

### onMessage

static

onMessage(msg)

Handles all messages coming from the Video object.
Must be called for each message received on the roMessagePort.

| #### Parameter ||
|---|---|
| msg | object The message from the roVideo port. |

### replaceAdTagParameters

static

replaceAdTagParameters(adTagParameters)

Replaces all of the ad tag parameters to be used for the upcoming ad requests for a
live stream. Note that this call is a no-op for VOD streams.

| #### Parameter ||
|---|---|
| adTagParameters | string The new ad tag parameters. |

### start

static

start()

Starts playback of the stream.