Set up Roku 2.x for streaming media
The Adobe Media SDK 2.x for Roku (adbmobile.brs) sends streaming media data from Roku channels written in BrightScript directly to Adobe Analytics. It also collects audience data through Audience Manager and measures engagement through media events.
-
Prerequisites:
- Complete the Analytics-only implementation overview.
- Download the Media SDK for Roku.
- Include an API in your media player to subscribe to player events, and an API that provides player information such as the media name and the playhead position.
Install the SDK
The AdobeMobileLibrary-2.*-Roku.zip download contains two components:
adbmobile.brs: the library file. Copy it into your channel’spkg:/source/directory.ADBMobileConfig.json: the SDK configuration file, customized for your app.
For SceneGraph channels, also copy adbmobileTask.brs and adbmobileTask.xml into your pkg:/components/ directory. See SceneGraph support.
Configure ADBMobileConfig.json
The configuration JSON has an exclusive mediaHeartbeat key for streaming media. Add ADBMobileConfig.json to your project source and set the mediaHeartbeat, marketingCloud, and analytics values:
{
"analytics": {
"rsids": "your-report-suite-id",
"server": "your-analytics-server"
},
"marketingCloud": {
"org": "YOUR-MCORG-ID@AdobeOrg"
},
"mediaHeartbeat": {
"server": "your-namespace.hb-api.omtrdc.net",
"publisher": "your-publisher-id",
"channel": "sample-channel",
"ssl": true,
"ovp": "sample-ovp",
"sdkVersion": "sample-sdk",
"playerName": "Roku Player"
}
}
serverpublisherchannelsslovpsdkVersionplayerNamemediaHeartbeat is incorrectly configured, the media module enters an error state and stops sending tracking calls. Ensure that your marketingCloud.org value includes @AdobeOrg.Initialize the SDK and process messages
Get an instance of the SDK with ADBMobile(). The Experience Cloud Visitor ID service generates a visitor ID that is included on all hits.
processMessages and processMediaMessages in your main event loop every 250 ms so that the SDK sends pings properly.adb = ADBMobile()
' In your main event loop, every ~250 ms:
adb.processMessages()
adb.processMediaMessages()
processMessagesprocessMediaMessagesTrack media events
Track each media event by calling its SDK method. See the Roku 2.x tab on each event and variable page for the exact calls, builders, and constants.
A typical session begins by building a media object and calling mediaTrackSessionStart:
adb = ADBMobile()
mediaInfo = adb_media_init_mediainfo("Mr. Robot", "video-123", 128.0, adb.MEDIA_STREAM_TYPE_VOD, adb.MEDIA_TYPE_VIDEO)
contextData = { "a.media.show": "Mr. Robot" }
adb.mediaTrackSessionStart(mediaInfo, contextData)
The global adb_media_init_* builders create the media, ad, ad-break, chapter, and QoS objects used by the tracking calls:
adb_media_init_mediainfo(name, id, length, streamType, mediaType)adb_media_init_adinfo(name, id, position, length)adb_media_init_adbreakinfo(name, startTime, position)adb_media_init_chapterinfo(name, position, length, startTime)adb_media_init_qosinfo(bitrate, startupTime, fps, droppedFrames)Standard metadata is passed as an associative array of a.media.* keys (the SDK also defines named constants such as MEDIA_VideoMetadataKeySHOW for these keys). See the Variables pages for the key that corresponds to each dimension.
Configure the Experience Cloud Visitor ID, privacy, and logging
The following methods on the ADBMobile() instance manage identity, privacy, and debugging:
visitorMarketingCloudID()visitorSyncIdentifiers(identifiers)setAdvertisingIdentifier(rida)getRIDA() API.getAllIdentifiers()setPrivacyStatus(status)getPrivacyStatus()setDebugLogging(flag)getDebugLogging()true if debug logging is enabled.SceneGraph support scenegraph
The Roku SceneGraph XML framework cannot call the legacy BrightScript SDK APIs directly, because the SDK uses components (such as threads) that are not available to a SceneGraph app. To bridge this gap, the SDK provides a connector that returns a SceneGraph-compatible instance exposing the same APIs, plus a callback mechanism for APIs that return data.
The bridge has three parts:
adbmobileTasknode: a SceneGraph task node that executes SDK APIs on a background thread and returns data to your scenes.- Connector instance: wraps all legacy public APIs and communicates with the
adbmobileTasknode. API_RESPONSEcallback: the field your app observes to receive return values from getter APIs.
To initialize the SDK in a SceneGraph channel:
-
Import
adbmobile.brsinto your scene:code language-brightscript <script type="text/brightscript" uri="pkg:/source/adbmobile.brs" /> -
Create the
adbmobileTasknode, get the connector instance, and load the SceneGraph constants:code language-brightscript m.adbmobileTask = createObject("roSGNode", "adbmobileTask") m.adbmobile = ADBMobile().getADBMobileConnectorInstance(m.adbmobileTask) m.adbmobileConstants = m.adbmobile.sceneGraphConstants() -
Register a callback to receive response objects for APIs that return data:
code language-brightscript m.adbmobileTask.ObserveField(m.adbmobileConstants.API_RESPONSE, "onAdbmobileApiResponse") function onAdbmobileApiResponse() as void responseObject = m.adbmobileTask[m.adbmobileConstants.API_RESPONSE] if responseObject <> invalid methodName = responseObject.apiName retVal = responseObject.returnValue if methodName = m.adbmobileConstants.PRIVACY_STATUS print "Privacy status: " + retVal end if end if end function
The connector instance (m.adbmobile) exposes the same media methods as the legacy SDK (mediaTrackSessionStart, mediaTrackPlay, mediaTrackPause, mediaTrackComplete, mediaTrackSessionEnd, mediaTrackError, mediaTrackEvent, mediaUpdatePlayhead, and mediaUpdateQoS) so the calls shown on the event and variable pages work the same way. Setter APIs are called directly; getter APIs return their values through the API_RESPONSE callback.
Next step
Once your implementation is complete, you can Set up reporting for Analytics-only implementations.