Skip to main content
GlobalTV Roku is a native Roku SceneGraph (RSG) channel written in BrightScript. The application is split into two physical layers — pure BrightScript logic under source/ and SceneGraph XML+BRS components under components/ — that communicate through the RSG scene tree and shared global state.

Roku SceneGraph fundamentals

Roku SceneGraph is a declarative UI framework built on a node tree. Every visual element and background task is a node. Key system concepts used by this app:
  • Scene treeMainScene extends the built-in Scene node and is the root of the entire tree. All screens and tasks are children of MainScene.
  • roSGScreen — the Roku system object that renders the SceneGraph. Created in main.brs, it owns a single MainScene.
  • roMessagePort — the event loop in main.brs. The while true loop waits on this port to receive roSGScreenEvent, roSGNodeEvent, roInputEvent, and roDeviceInfoEvent messages.
  • Tasks — SceneGraph Task nodes run BrightScript on a background thread. They expose observable fields so the scene thread can react to results without blocking the UI.
  • observeField / onChange — the wiring mechanism. When a field value changes, RSG calls the registered handler on the same thread as the observer.
  • m.global — a globally shared roSGNode accessible from every component and task in the app. AppState.brs initialises all fields on it at startup.

Source layer (source/)

Code under source/ runs on the render thread inside MainScene. It is loaded via <script> tags in MainScene.xml.

Components layer (components/)

Screens

MainScene, SplashScreen, OnboardingScreen, LoginScreen, MainScreen, PlayerScreen, SettingsScreen — the full user-facing UI hierarchy from launch through playback.

Background tasks

HandshakeTask, AuthTask, PlaylistTask, ConnectivityTask, AdsPollingTask, MetricsTask, ServerProbeTask — all network I/O runs off the render thread.

Ad system

AdManager coordinates three format renderers: AdFormatA, AdFormatB, and AdFormatC. Format C reduces the video viewport height. Ad data arrives from AdsPollingTask every 10 seconds.

Overlays

channelBanner shows channel name, number, logo, and live status. numberOverlay handles direct numeric channel entry. Both overlay the live video during playback.

Component responsibilities

Utility layer

All utilities are pure BrightScript functions loaded as <script> includes into MainScene.xml. They carry no node state and can be called from any script that shares the same component scope.

Design resolution and safe area

GTV_GetDesignSize() detects the display mode (roDeviceInfo.GetDisplayMode()) and returns 1920×1080 or 1280×720. GTV_GetSafeArea() applies the uiSafeMarginPct registry value (0–10 %) to compute inset bounds. All screens call ApplyResponsiveLayout() on init and whenever currentDesignResolution changes, keeping the layout consistent across FHD and HD Roku models.