PlayerScreen handles all live stream playback for GlobalTV. It manages the Video node lifecycle, the channel banner overlay, direct channel number entry, connectivity monitoring, ad rendering, and error recovery.
Stream playback
Streams are played as HLS (streamFormat = "hls", live = true). The Video node fills the full safe area by default. URLs from the playlist are normalized before use to handle hls:// and hlss:// prefixes:
Channel overlay system
TheChannelBanner overlay (channelBanner node) shows channel number, name, logo, group, and current status (“Conectando…”, “En vivo”, “Reconectando la transmisión”, etc.). Network status is reflected in m.banner.networkOnline.
The overlay is triggered by:
- Pressing Left in the player → sets
m.top.requestOverlay, whichMainScenehandles by settingoverlayMode = trueonMainScreen - Pressing OK once →
ArmSettingsShortcut()is called and the banner shows “En vivo” - Pressing OK a second time while the shortcut is armed → opens
SettingsScreen
MainScreen is in overlay mode, directional keys and OK are routed through RouteOverlayKey() to MainScreen.HandleOverlayKey().
Number overlay (direct channel entry)
TheNumberOverlay node allows direct channel tuning by number. Any digit key press adds to the buffer:
numberCommitted fires and the player tunes to the matching channel:
Ad integration during playback
Three tasks support the ad system:| Task | Purpose |
|---|---|
AdsPollingTask | Handshake with ad backend, polls active snapshot |
AdManager | Renders ad formats A, B, C on top of video |
MetricsTask | Tracks impression events |
AdManager signals a videoHeightReduction and videoOffsetY to shrink and offset the video viewport, making room for the ad below:
allAdsHidden), the video is immediately restored to full size.
Error handling and reconnection
Errors from theVideo node trigger OnVideoError(). The player retries automatically up to RETRY_MAX = 3 times with a 2-second delay between attempts:
RETRY_MAX failures, an ErrorDialog is shown with Retry and Back options.
Error classification
Inactive session (401/403)
Inactive session (401/403)
Detected by keywords such as
inactivo, subscriberStatus, or HTTP 401/403 with forbidden. Stops the stream, sets m.top.userInactive = true, and navigates back to login.Password changed (471)
Password changed (471)
Detected by keywords like
password, cambi, token revoked. Same flow as inactive session with AUTH_REASON_PASSWORD_CHANGED.Auto-recoverable errors
Auto-recoverable errors
Timeout (
-1), HTTP response errors, and connection errors set m.lastErrorCanAutoRecover = true. If network is restored while the error dialog is open, RestartStream() is called automatically without user interaction.Stream finished
Stream finished
A
finished state on a live stream triggers RestartStream() immediately.Freeze detection
A watchdog timer (watchdogTimer) runs every 10 seconds (FREEZE_CHECK_MS = 10000ms). It compares the current video.position against the last recorded value. If the position has not changed while the state is playing, the stream is considered frozen and restarted:
FREEZE_CHECK_MS = 10000 is defined in AppConstants. The XML timer duration="10" directly matches this value.Connectivity monitoring
A separateConnectivityTask runs in the background and fires OnConnectivityChanged() when the internet state changes. A netCheckTimer also polls every 30 seconds (NET_RETRY_MS = 30000ms).
When connectivity is lost:
- The video is stopped
- An
OfflineDialogis shown with a Retry button - When connectivity is restored,
RestartStream()is called automatically
Channel navigation within the player
| Key | Action |
|---|---|
| Up | Play next channel (currentIndex + 1) |
| Down | Play previous channel (currentIndex - 1) |
| Left | Open MainScreen overlay |
| Digit (0-9) | Append to number overlay buffer |
| OK (first press) | Arm settings shortcut, show status hint |
| OK (second press) | Open SettingsScreen |
| Back | Exit player, return to MainScreen overlay |