Roku SDK API Reference

Complete reference for the public methods and observable fields exposed by the StreamLayer Roku SDK node.

This page documents the public API of the StreamLayer Roku SDK. The SDK is delivered as a SceneGraph node (StreamLayer) that you add to your scene. All methods are invoked with callFunc on that node, and state is read back through observable fields.

For setup instructions, see the Integration Guide. For version history, see the Changelog.

' The SDK node, created from the SceneGraph component
m.streamLayer = m.top.createChild("StreamLayer")

Invocation pattern

Every method below is called through the node, for example:
m.streamLayer.callFunc("setEvent", "nba-lakers-2026-05-28"). Calling a method
that is not available in the current SDK mode is a safe no-op — it is logged,
not thrown.


Table of Contents


Initialization & Lifecycle

initSdk

function initSdk(params as object) as boolean

Initializes the SDK: configures logging, analytics, and ad modes, validates the optional player reference, loads configuration, and starts the SceneGraph runtime. Call this once before any other method.

FieldTypeRequiredDescription
apiKeystringYesYour SDK API Key from StreamLayer Studio.
apiUrlstringNoAPI base URL. Defaults to the configured environment URL when empty.
playerRefroSGNodeNoThe host Video node. Must expose control and state fields.
isLoggingEnabledbooleanNoEnables SDK logging. Default false.
isAnalyticsEnabledbooleanNoEnables analytics reporting. Default false.
isPauseAdsEnabledbooleanNoEnables pause ad units. Default true.
isVastModeEnabledbooleanNoRuns the SDK in VAST mode (host-supplied pause ads). Default false.
isPrefetchEnabledbooleanNoPrefetches VAST pause ad creatives. Default false.

Returns: booleantrue when parameters are accepted and initialization starts; false when params is missing.

Example:

success = m.streamLayer.callFunc("initSdk", {
    apiKey: "your-sdk-api-key"
    apiUrl: "https://api.streamlayer.io"
    playerRef: m.videoPlayer
    isLoggingEnabled: true
    isAnalyticsEnabled: true
    isVastModeEnabled: false
})
' success = true → the StreamLayer Element runtime is initializing

attachPlayer

sub attachPlayer(ref as object)

Attaches (or replaces) the host video player after initialization. The reference must be an roSGNode that exposes control and state fields; otherwise it is rejected with a warning and ignored.

ParameterTypeDescription
refroSGNodeThe host Video node to attach.

Example:

m.streamLayer.callFunc("attachPlayer", m.videoPlayer)

setEvent

sub setEvent(hostEventId as string)

Binds the SDK to a host event so the StreamLayer Element starts receiving interactive content for it. The player must be attached first.

ParameterTypeDescription
hostEventIdstringThe host's event identifier for the current stream.

Example:

m.streamLayer.callFunc("setEvent", "nba-lakers-2026-05-28")

getVersion

function getVersion() as object

Returns the running SDK version and product name.

Returns: object with:

FieldTypeDescription
versionstringSemantic version string, for example 2.8.0-001.
namestringAlways "StreamLayer Roku SDK".

Example:

info = m.streamLayer.callFunc("getVersion")
print info.name + " v" + info.version
' StreamLayer Roku SDK v2.8.0-001

Playback & Pause Ads

setPauseState

sub setPauseState(pauseState as boolean)

Notifies the SDK that the host player's pause state changed. While a promo or notification is visible, the call is ignored. Pausing also cancels any scheduled overlay.

ParameterTypeDescription
pauseStatebooleantrue when the player is paused, false when playing.

Example:

m.streamLayer.callFunc("setPauseState", true)

showPauseAd

sub showPauseAd(params = invalid)

Requests a pause ad unit for the current event. In VAST mode you must pass a params object containing the creative URL; in full mode the SDK loads its own pause ad units and the argument is optional. The call is ignored if no event is set.

FieldTypeRequiredDescription
paramsobjectVAST mode onlyObject with the VAST creative, for example { vastUrl: "..." }.

Example:

' VAST mode
m.streamLayer.callFunc("showPauseAd", { vastUrl: "https://ads.example.com/vast.xml" })

' Full mode
m.streamLayer.callFunc("showPauseAd")

closePauseAd

sub closePauseAd()

Closes the active pause ad unit. Routes to the external (VAST) or internal close path depending on the current mode.

Example:

m.streamLayer.callFunc("closePauseAd")

setVastModeEnabled

sub setVastModeEnabled(enabled as boolean)

Switches the SDK between full mode and VAST mode at runtime. No-ops if the mode is already set.

ParameterTypeDescription
enabledbooleantrue for VAST mode, false for full mode.

Example:

m.streamLayer.callFunc("setVastModeEnabled", true)

resumeRequested

sub resumeRequested()

Signals that playback should resume — typically from the pause ad unit's Play button. Sets the observable isResumeRequested field to true so the host can resume its player.

Example:

m.streamLayer.callFunc("resumeRequested")

Overlay & Focus

closeOverlay

sub closeOverlay()

Closes all active StreamLayer Element overlays and any open pause ad unit, cancels any scheduled overlay, and resets the promo and notification visibility flags.

Example:

m.streamLayer.callFunc("closeOverlay")

setFocus

sub setFocus(value)

Forwards focus to whichever surface is currently visible — the promo, notification, or pause ad presenter.

ParameterTypeDescription
valuebooleantrue to give the visible surface focus, false to remove it.

Example:

m.streamLayer.callFunc("setFocus", true)

Observable Fields

Read these fields, or observe them with observeField, to react to SDK state. All are set by the SDK; the host observes them.

FieldTypeDescription
logstringLatest log line emitted by the SDK (when logging is enabled).
disableFocusbooleanWhen true, the host should not hand focus to the SDK.
isPromoVisiblebooleantrue while a promo (interactive ad unit) overlay is on screen.
isNotificationVisiblebooleantrue while a Live Moment Notification is on screen.
isPauseAdVisiblebooleantrue while a pause ad unit is on screen.
isResumeRequestedbooleanSet to true when the SDK requests stream resume. The host resumes playback and may reset it.

Example:

m.streamLayer.observeField("isResumeRequested", "onResumeRequested")

sub onResumeRequested(event as object)
    if event.getData() = true then m.videoPlayer.control = "resume"
end sub