ComponentController
Extends: Group
Description
The ComponentController component implements the basic default view management. It essentially implements the view stack. Further, the component also handles view to view navigation, back button handling, and showing and closing views. The developer can use ComponentController to call the show()
function to add views to the view stack and make them visible. Developers do not need to create ComponentController instances in their channels. This is created on the channel's scene by SGDEX if the scene is extended from BaseScene.
Interface
Fields
Field | Type | Default | Use |
---|---|---|---|
currentView | Node | - | Holds the reference to the view that is currently shown |
allowCloseChannelOnLastView | Boolean | True | If true, the channel closes when the back button is pressed or if the previous view set the view's close field to true |
allowCloseLastViewOnBack | Boolean | True | If true, the current view is closed, and the user can open another view through the new view's wasClosed callback |
Functions
Function | Description |
---|---|
show | Called to add a view to the view stack and make it visible |
Example
BaseScene
Extends: Scene
Description
As with any other Roku SceneGraph based channel, SGDEX channels implement a main scene that host all other channel views and components; this scene is derived from BaseScene. BaseScene provides a variety of default functionality. The function show()
should be overridden in the channel to implement any view specific initialization.
Interface
Fields
Field | Type | Default | Description |
---|---|---|---|
ComponentController | Node | - | This field holds the ComponentController instance created by SGDEX for use in the channel Read Only |
exitChannel | Boolean | False | Exits channel if set to true Write Only |
theme | Associative array | { } | Theme is used to customize the appearance of all SGDEX views For common fields, see SGDEXComponent For view-specific views, refer to:
These attributes can also be set on specific view instances. For example, this specific grid is set to have red text: Use view's theme field to set its theme view = CreateObject("roSGNode", "GridView") view.theme = { textColor: "FF0000FF" }
Because textColor is globally set to red, the detailsView instance will have red text as the theme overrides rides in the hierarchy impact details views. |
updateTheme | Associative array | { } | Used to updatethemeattributes. This field can be set to a theme config similar to the original theme field. Only the attributes that need to be changed have to be set Note: When changing many theme fields, do this withas few updates as possible to prevent frequent redraws |
Example
ContentHandler
Extends: Task
Description
Content Handlers are responsible for all content loading tasks in SGDEX. Channels typically extend ContentHandler to implement specific content or data loading tasks. ContentHandlers should implement a function called GetContent()
. This function is called by SGDEX, allowing the handler to make application specific API calls or perform other operations to load the content associated with the handler.
Interface
Fields
Field | Type | Default | Description |
---|---|---|---|
content | Node | - | Modified in the GetContent() function by adding/updating the Content Nodes being rendered by the associated view |
offset | Integer | 0 | When working with paged data, offset reflects which page of content SGDEX is expecting to populate using ContentHandler |
pageSize | Integer | 0 | When working with paged data, pageSize reflects the number of items SGDEX is expecting to populate using ContentHandler |
failed | Boolean | False | Indicates if the ContentHandler failed to load the requested content If If the |
HandlerConfig | Associative array | { } | Contains a reference to the ContentHandler config |
Example
EntitlementHandler
Extends: Task
Description
Entitlement Handlers are used together with the EntitlementView component to let developers leverage Roku Billing for buildinng a basic SVOD for their channels. The Entitlement Handler is used to let SGDEX know about the subscription products associated with the channel.
The developer can implement a Handler in the channel that extends EntitlementHandler. In this handler, they can override two functions:
ConfigureEntitlements(config)
[Required]OnPurchaseSuccess(transactionData)
[Optional]
For ConfigureEntitlements
, the channel can update the config with its own params.
The config should contain the following fields:
config.products [Array]
of AAs having fields
config.products.code [String]:
Product code in ChannelStoreconfig.products.hasTrial [Boolean]:
True if the product's trial period has expired
OnPurchaseSuccess
is a callback that allows the developer to inject some custom logic on purchase success by overriding this subroutine. The default implementation for this callback is set to taking no action.
Interface
Fields
Field | Type | Default | Description |
---|---|---|---|
content | Node | - | The content node from EntitlementView is passed here; the developer can use it in the handler |
view | Node | - | It refers to theEntitlementViewwhere the specific handler was created |
Example
RAFHandler
Extends: Task
Description
The RAFHandler component is the SGDEX wrapper for the Roku Ad Framwork (RAF). The developer extends this component in the channel and implements ConfigureRAF(adIface as Object).
They can further implement any desired configuration supported by RAF in ConfigRAF()
.
Example
SGDEXComponent
Extends: Group
Description
This is the base component for all SGDEX views.
Interface
Fields
Field | Type | Default | Description |
---|---|---|---|
theme | Associative array | { } | Theme is used to set view specific theme fields To update a value, use For a list of the common attributes for all view, refer to Common theme attributes See the theme attribute description in the BaseScene component section above |
updateTheme | Associative array | { } | Used to update view specific theme fields Usage is same as theme field but here, only the field that needs to be updated is set For global updates, set the |
style | String | "" | Indicates what style to use for a view The style is view specific For example, GridView supports standard and hero styles |
posterShape | String | "" | Indicates what poster shape to use for the posters rendered on the view |
content | Node | - | Holds the view content. The content structure is defined by the specific view |
close | Boolean | False | A control field that tells the view manager to close a view |
wasClosed | Boolean | False | Indicates when a view is closed and removed from the view manager |
saveState | Boolean | False | Indicates when a view is hidden, and a new top view is opened |
wasShown | Boolean | False | Indicates when a view was shown for the first time or restored after the top view was closed |
CategoryListView
Extends: SGDEXComponent
Description
CategoryListView represents the SGDEX category list view that has two lists; one for categories and another for the items in the category.
Interface
Fields
Field | Type | Default | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
initialPosition | Vector2D | [0, 0] | Indicates where initial focus is set on the itemsList: 1st coordinate = category, 2st coordinate = item in this category | ||||||||||||||||||||
selectedItem | Vector2D | [0, 0] | Array with 2 integers; returns the section and item in the current section that was selected Read Only | ||||||||||||||||||||
focusedItem | Integer | 0 | Returns the currently focused item index (within all categories) Read Only | ||||||||||||||||||||
focusedItemInCategory | Integer | 0 | Returns the currently in focus item index from the current focusedCategory | ||||||||||||||||||||
focusedCategory | Integer | 0 | Returns the currently in focus category index | ||||||||||||||||||||
jumpToItem | Integer | 0 | Jumps to an item in the items list (within all categories) This field must be set after setting the content field only Write Only | ||||||||||||||||||||
animateToItem | Integer | 0 | Animates to an item in the items list (within all categories) Write Only | ||||||||||||||||||||
jumpToCategory | Integer | 0 | Jumps to a category Write Only | ||||||||||||||||||||
animateToCategory | Integer | 0 | Animates to a category Write Only | ||||||||||||||||||||
jumpToItemInCategory | Integer | 0 | Jumps to an item in the current category Write Only | ||||||||||||||||||||
animateToItemInCategory | Integer | 0 | Animates to an item in the current category Write Only | ||||||||||||||||||||
theme | Associative array | { } | Used to change the color of the grid view elements Note: Set TextColor and focusRingColor to have a generic theme and only change attributes that would not use it For all the Possible values of the field, refer to CategoryListView theme attributes | ||||||||||||||||||||
content | Node | - | Follows the model below to build a proper content node Possible fields Category fields:
Item List fields:
|
Example
VideoView
Extends: SGDEXComponent
Description
VideoView is the SGDEX component is used by channels to play content. It includes a number of different features, including:
- Playback of a single video or a video playlist;
- Loading of content via
HandlerConfigVideo
before playback; - Showing endcards view after a video playback ends;
- Loading of endcard content via
HandlerConfigEndcard
before the video ends for performance benefit; - Handling of RAF -
handlerConfigRAF
is set in the content node; - Video.state field is aliased to make tracking of states easier;
- Theme support
Interface
Fields
Field | Type | Default | Description |
---|---|---|---|
endcardCountdownTime | Integer | 10 | Returns the endcard countdown time Indicates how long the endcard is shown for before the next video starts playing |
endcardLoadTime | Integer | 10 | Returns the time at which the video ends so that the endcard content can start loading |
alwaysShowEndcards | Boolean | False | Config that indicates when the VideoView shows the endcard with the default next item and the repeat button even if the content getter is not specified by the user |
isContentList | Boolean | True | Indicates if the content is a playlist or an individual item |
jumpToItem | Integer | 0 | Jumps to an item in the playlist This field must be set after setting the content field |
control | String | "" | Controls "play" and "prebuffer" and starts loading content from Content Getter If any other control is defined, itissetdirectlyto the video node |
endcardTrigger | Boolean | False | Trigger to notify channel that endcard loading has started |
currentIndex | Integer | -1 | Indicates what is the index of the current item - index of a child in the content |
state | String | "" | State of the Video Node |
position | Integer | 0 | Playback position in seconds |
duration | Integer | 0 | Playback duration in seconds |
currentItem | Node | - | Indicates the current item in the content node If changing this field manually, unexpected behavior can occur Read Only |
endcardItemSelected | Node | - | The content node of the selected endcard item |
disableScreenSaver | Boolean | False | This is an alias of the video node's field of the same name Refer to Video nodes for the description of the field |
theme | Associative array | { } | Theme is used to change the color of the grid view elements Note: Set For the possible VideoView values, refer to: For the possible EncardView values, refer to : |
Example
DetailsView
Extends: SGDEXComponent
Description
DetailsView is the SGDEX equivalent of the springboard screen that was used in the legacy Roku SDK. It can be used to show poster art for content, text descriptions, and a set of action buttons defined by the buttons field. These buttons support the content metadata fields listed below for customizing the text and images displayed in the button.
Fields
Field | Type | Description |
---|---|---|
TITLE | String | The label for the list item |
HDLISTITEMICONURL | Uri | The image file for the icon to be displayed to the left of the list item label when the list item is not in focus |
HDLISTITEMICONSELECTEDURL | Uri | The image file for the icon to be displayed to the left of the list item label when the list item is in focus |
Interface
Fields
Field | Type | Default | Description |
---|---|---|---|
buttons | Node | - | The content node for a button's node Has children with an ID and a title that is shown on the view |
isContentList | Boolean | True | Tells details view how your content is structured Write Only |
allowWrapContent | Boolean | True | Defines the logic of showing content when pressing left on the first item or pressing right on the last item If set to true, start playback from the first item (when pressing right) or starts it from the last item (when pressing left) Write Only |
currentItem | Node | - | Returns the currently displayed item This field is set when the Content Getter finishes loading extra meta-data Read Only |
itemFocused | Integer | 0 | Indicates which item is currently focused |
jumpToItem | Integer | 0 | Manually focuses on the desired item Must be set after setting the content field Write Only |
buttonFocused | Integer | 0 | Indicates which button is focused Read Only |
buttonSelected | Integer | 0 | Is set when a button is selected by the user Observed in the channel Can be used to show the next screen or start a playback Read Only |
jumpToButton | Integer | 0 | Interface for setting focused button Write Only |
theme | Associative array | { } | Controls the color of visual elements For a list of all the possible values, refer to DetailsView theme attributes |
GridView
Extends: SGDEXComponent
Description
The GridView component defines a standard content grid. In conjunction with ContentHandlers
, SGDEX grids can be implemented to support:
- Content loading;
- Lazy loading of the rows and an item in the row;
- Lazy loading of the rows when a user is not browsing the grid
Interface
Fields
Field | Type | Default | Description |
---|---|---|---|
rowItemFocused | Vector2D | [0, 0] | Updated when focused item changes Value is an array containing the index of the row and the items that were focused |
rowItemSelected | Vector2D | [0, 0] | Updated when an item is selected Value is an array containing the index of the row and the items that were selected |
jumpToRowItem | Vector2D | [0, 0] | Sets grid focus to a specified item This field must be set after setting the content field only |
theme | Associative array | { } | Controls the color of the visual elements For the possible values of Grid view theme, refer to Gridview theme attributes |
style | String | "" | Indicates what grid UI is used Possible values
|
posterShape | String | "" | Controls the aspect ratio of the posters on the grid Possible values
|
content | Node | - | Controls how SGDEX loads the content for the view Content metadata field that can be used: Here,
Note: Passing the row itself or grid via fields might cause memory leaks Set the row ContentHandler when parsing content in "CHRoot," so that it is called when data for that row is needed |
Example
EntitlementView
Extends: SGDEXComponent
Description
The EntitlementView gives developers a way to build a basic SVOD experience in their channel. It can be used to walk a user through the purchase of a Roku Billing subscription and also be used after a purchase to enforce entitlement rules by checking whether a user owns a valid subscription.
There are two implementations of this view:
- A silent check of the available subscriptions;
- A check to show Entitlement view/flow
To pass configs to view, a user implements a handler that extends EntitlementHandler.
Interface
Fields
Field | Type | Default | Description |
---|---|---|---|
isSubscribed | Boolean | False | [ObserveOnly] Sets to true/false and shows if a user is subscribed after:
|
silentCheckEntitlement | Boolean | False | Initiates silent entitlement checking (headless mode) Write Only |
Example