The Roku Core SDK is an HTTP networking library written in Brightscript. Roku Core helps developers to quickly and easily fetch data from their instance of the dotstudioPRO CMS, so they can focus on the UI and UX of their application. Roku Core includes first-class Brightscript support.
Requirements
Platform | Minimum Version | Status |
---|---|---|
Roku | 11.0+ | Fully Tested |
Installation
Use the below command to install the Roku Core SDK in your Roku Native project:
git clone https://github.com/dotstudiopro/core-roku
Copy the core-roku/dotstudioPRO-core folder into your channel, ensuring that the path to the folder is pkg:/components/dotstudioPRO-core.
OR
Use the Xcopy command to copy the dotstudioPRO-core folder and place it in the Apps pkg:/components folder.
Xcopy [source File Path] [destination File Path] /E /H /C /I
How to Use
To Use any core api first create Task roSGNode in any Scene .brs file
Here we Call AccessTokenTask Task
AccessToken Data
To get AccessToken data, dispatch gettoken()
Function gettoken()
if m.global <> invalid and m.global.company_api_key <> invalid then
m.TokenTask = CreateObject("roSGNode", "AccessTokenTask")
m.TokenTask.company_api_key = m.global.company_api_key ("get company_api_key from global variable file in source folder "appConfig.brs")
m.TokenTask.functionName = "getToken"
m.TokenTask.ObserveField("api_token", "tokenresponse")
m.TokenTask.ObserveField("api_error", "onErrorResponse")
m.TokenTask.control = "RUN"
end if
End Function
Function tokenresponse( event )
api_token = event.getData()
if api_token.token <> invalid then
print "******** AccessTokenTask Response *********"
print "Access Token: " m.global.token
end if
End Function
Most calls to the dotstudioPRO API require an access token. Dispatch a AccessTokenTask to acquire an access token to use with subsequent requests.
Homepage Data
To get Homepage data, dispatch LoadHomePageData():
sub LoadHomePageData()
m.PageTask = CreateObject("roSGNode", "PageComponentTask")
m.PageTask.pagetype = "homepage"
m.PageTask.functionName = "getPageData"
m.PageTask.ObserveField("pageCategories", "homePageResponse")
m.PageTask.ObserveField("api_error", "onErrorResponse")
m.PageTask.control = "RUN"
end sub
sub homePageResponse(event)
if event.getData() <> invalid then
m.categoryObject = event.getData()
print "******** homePageResponse Response *********"
?"HomePage Response:" event.getData()
else
print "******** Error *********"
print "Access token get first"
end if
end sub</>
Movies Page Data
To get Movies page data, dispatch LoadMoviePageData()
sub LoadMoviePageData()
m.PageTask = CreateObject("roSGNode", "PageComponentTask")
m.PageTask.pagetype = "movies"
m.PageTask.functionName = "getPageData"
m.PageTask.ObserveField("pageCategories", "moviePageResponse")
m.PageTask.ObserveField("api_error", "onErrorResponse")
m.PageTask.control = "RUN"
end sub
sub moviePageResponse(event)
if event.getData() <> invalid then
print "******** moviePageResponse Response *********"
?"Movies Page Response:" event.getData()
else
print "******** Error *********"
print "Access token get first"
end if
end sub
Series Page Data
To get Series page data, dispatch LoadSeriesPageData():
sub LoadSeriesPageData()
m.PageTask = CreateObject("roSGNode", "PageComponentTask")
m.PageTask.pagetype = "series"
m.PageTask.functionName = "getPageData"
m.PageTask.ObserveField("pageCategories", "seriesPageResponse")
m.PageTask.ObserveField("api_error", "onErrorResponse")
m.PageTask.control = "RUN"
end sub
sub seriesPageResponse(event)
if event.getData() <> invalid then
print "******** SeriesPageResponse Response *********"
?"Series Page Response:" event.getData()
else
print "******** Error *********"
print "Access token get first"
end if
end sub</>
Categories Data
To get Category data, dispatch getCategory()
sub getCategory()
if m.categoryObject <> invalid and m.categoryObject[0] <> invalid then
m.CategoryTask = CreateObject("roSGNode", "CategoryTask")
m.CategoryTask.category = m.categoryObject[0] (First Category contant)
m.CategoryTask.functionName = "getCategory"
m.CategoryTask.ObserveField("categorydata", "CategoryDetailResponse")
m.CategoryTask.ObserveField("api_error", "onErrorResponse")
m.CategoryTask.control = "RUN"
else
print "******** Error *********"
print "Get any page component api"
end if
end sub
sub CategoryDetailResponse(event)
if event.getData() <> invalid then
print "******** CategoryDetailResponse Response *********"
?"Category Detail Response:" event.getData()
else
print "******** Error *********"
print "Access token get first"
end if
end sub
Channel Data
To retrieve data for an individual channel, dispatch LoadChannelDetailData().
sub LoadChannelDetailData()
if m.categoryObject <> invalid and m.categoryObject[0].channels[0] <> invalid then
m.ChannelTask = CreateObject("roSGNode", "ChannelTask")
m.ChannelTask.channel = m.categoryObject[0].channels[0](First channel from First Category contant)
m.ChannelTask.functionName = "getChannel"
m.ChannelTask.ObserveField("channeldata", "ChannelDetailResponse")
m.ChannelTask.ObserveField("api_error", "onErrorResponse")
m.ChannelTask.control = "RUN"
else
print "******** Error *********"
print "Get Category Deatil first"
end if
end sub
sub ChannelDetailResponse(event)
if event.getData() <> invalid then
print "******** ChannelDetailResponse Response *********"
?"Channel Detail Response:" event.getData()
else
print "******** Error *********"
print "Access token get first"
end if
end sub
Find Channels Data
To find channels data, dispatch FindChannelsData().
sub FindChannelsData()
m.FindChannelsTask = CreateObject("roSGNode", "FindChannelsTask")
m.FindChannelsTask.searchedKeyWord = "the" (search keyword)
m.FindChannelsTask.functionName = "FindChannels"
m.FindChannelsTask.ObserveField("channels", "FindChannelsResponse")
m.FindChannelsTask.ObserveField("api_error", "onErrorResponse")
m.FindChannelsTask.control = "RUN"
end sub
sub FindChannelsResponse(event)
if event.getData() <> invalid then
print "******** FindChannelsResponse Response *********"
?"Find Channels Response:" event.getData()
else
print "******** Error *********"
print "Access token get first"
end if
end sub
EPG Channel Data
To get EPG channels data, dispatch LoadEPGChannels().
sub LoadEPGChannels()
m.LoadTask = CreateObject("roSGNode", "EpgComponentTask")
m.LoadTask.functionName = "LoadEPG"
m.LoadTask.ObserveField("epgChannels", "epgdataresponse")
m.LoadTask.ObserveField("api_error", "onErrorResponse")
m.LoadTask.control = "RUN"
end sub
sub epgdataresponse(event)
if event.getData() <> invalid then
print "******** EpgComponentTask Response *********"
?"EpgComponent Channels:" event.getData()
m.EPGChannel = event.getData()[0].programs[0]
else
print "******** FiledownloadTask Error *********"
print "Access token get first"
end if
end sub</>
EPG Program Data
To get EPG channels program data, dispatch LoadEPGChannelProgram().
sub LoadEPGChannelProgram()
if m.EPGChannel <> invalid
m.LoadTask = CreateObject("roSGNode", "EpgComponentTask")
m.LoadTask.epgChannelprograms = m.EPGChannel (single program From Epg channel api response)
m.LoadTask.functionName = "LoadEPGProgram"
m.LoadTask.ObserveField("epgProgram", "epgprograndataresponse")
m.LoadTask.ObserveField("api_error", "onErrorResponse")
m.LoadTask.control = "RUN"
else
print "******** Error *********"
print "EpgChannel API call first"
end if
end sub
sub epgprograndataresponse(event)
if event.getData() <> invalid then
print "******** EpgProgramTask Response *********"
?"EpgChannel Program:" event.getData()
else
print "******** Error *********"
print "Access token get first"
end if
end sub</></>
Video Data
To get video data, dispatch VideoTaskData().
sub VideoTaskData()
m.VideoTask = CreateObject("roSGNode", "VideoTask")
m.VideoTask.videoID = "63d027d8259e8421100be6d5"
m.VideoTask.functionName = "getVideoDetail"
m.VideoTask.ObserveField("videoDetail", "VideoDetailResponse")
m.VideoTask.ObserveField("api_error", "onErrorResponse")
m.VideoTask.control = "RUN"
end sub
sub VideoDetailResponse(event)
if event.getData() <> invalid then
print "******** VideoDetailResponse Response *********"
?"Video Deatil Response:" event.getData()
else
print "******** Error *********"
print "Access token get first"
end if
end sub
</>
Features
The dotstudioPRO core-roku SDK offers robust support for Brightscript. It retrieves data from the API and generates typed objects, subsequently transmitting them to the UI. The following enumerates the classes and provides definitions for their data stores:
Classes
dotstudioPRO allows users to organize content in a top-down taxonomy. To learn more about the taxonomy and understand how to categories your content, create channels & videos and more, please visit out Content Taxonomy article.
Category
Represents a Category in the dotstudioPRO CMS. This class also contains all the channels contained within any specific category.
Key | Type | Description |
---|---|---|
Id | String | ID of the Category. |
Name | String | Category name. |
Description | String | Category description. |
Slug | String | Category slug. |
Poster | String | Category poster image. |
Logo | String | Category logo image. |
Wallpaper | String | Category wallpaper image. |
display_name | String | Category display name. |
channels | Array | Array of all channels assigned to the Category. |
The following child classes can inherit the properties of SPLTCategory.
ParentCategory (extends Category)
Contains an array of child categories. Useful for more advanced UI use-cases where multiple "levels" of categories are required.
Key | Type | Description |
---|---|---|
categories | Array | Array of categories. |
ContinueWatchingCategory (extends Category)
Contains an array of ContinueWatchingChannel, or the "continue watching"/resumptions data for a specific user.
WatchlistCategory (extends Category)
Contains an array of any channels added to "My List" for a specific user.
Channel
Represents a Channel in the dotstudioPRO CMS. This class also contains any child channels, playlists, or videos assigned to a specific channel.
Key | Type | Description |
---|---|---|
Id | String | Channel ID. |
Title | String | Channel title. |
Description | String | Channel description. |
Slug | String | Channel slug. |
Poster | String | Poster image. |
Wallpaper | String | Wallpaper image. |
spotlight_poster | String | Key-Art image. |
Logo | String | Channel logo. |
Rating | String | Content rating |
Year | String | Year of release or production. |
Language | String | Content language. |
Actors | Array | Array of actors appearing in content. |
Directors | Array | Array of directors for content. |
Writers | Array | Array of wroters for content. |
Tags | Array | Array of tags assigned to the channel. |
Genres | Array | Array of genres assigned to the channel. |
video_id | String | Video id of the channel. |
channel_type | String | Channel type. |
The following child classes can inherit the properties of Channel.
VideoChannel (extends Channel)
Contains a single VOD video, most commonly representing a VOD Film title.
Key | Type | Description |
---|---|---|
video | Video | Object instance of Video class. |
PlaylistChannel (extends Channel)
Contains an array of VOD videos, commonly representing a season of a series.
Key | Type | Description |
---|---|---|
videos | Array | Array video objects of the Video class. |
ParentChannel (extends Channel)
Contains an array of child channels, most commonly representing a series.
Key | Type | Description |
---|---|---|
childChannels | Array | Array of channel objects of the Channel class. |
EPGChannel (extends Channel)
Contains a Live Linear video, and an array of getChannelsFromEpgJsonChannels objects representing the EPG programming metadata.
Key | Type | Description |
---|---|---|
Programs | Array | Array of programs object of the Channel class. |
EPGChannelProgram
Represents a single Live Linear Channel's Electronic Program Guide (EPG) & program metadata.
Key | Type | Description |
---|---|---|
Id | String | Program ID. |
title | String | Program title. |
program_language | String | Program language. |
description | String | Program description. |
start_at | String | Program Start Timestamp (in seconds from 1 January, 1970). |
ends_at | String | Program End Timestamp (in seconds from 1 January, 1970). |
duration | String | Program duration. |
Video
Represents a single Video in the dotstudioPRO CMS.
Key | Type | Description |
---|---|---|
id | String | Video ID. |
title | String | Video title. |
description | String | Video description. |
short_description | String | Video short description. |
slug | String | Video slug. |
poster | String | Video poster image. |
wallpaper | String | Video wallpaper image. |
thumb | String | Video thumbnail image. |
thumbs | Array | Array of alternative video thumbnails. |
video_m3u8 | String | HLS playback URL used for playout. |
vmapUrl | String | VMAP URL containign the ad schedule for AVOD videos. Advertising must be configured in the CMS for this value to be present in the response. |
isLiveStream | Bool | Indicates whether the video is a live stream. |
genres | Array | Video genres. |
language | String | Video language. |
episode | String | Video episode number. |
season | String | Video season number. |
duration | Array | Video duration. |
isGeoblocked | String | Indicator if Video is Gioblocked or not. |
session_m3u8 | String | Session URL of the Video. |
company | String | Array of company detail. |
Error
Represents an Error from API response.
Key | Type | Description |
---|---|---|
statusCode | String | Error status code. |
message | String | Error message. |
Updated