A television streaming PWA combining adaptive video, a custom programme-guide API and session-aware channel access.
Application architecture
Built with HTML, CSS and vanilla JavaScript, with separate scripts for guide data, rendering, playback, authentication and panels. A central configuration maps channel names, guide IDs, numbering, logos and stream overrides. Guide rows are reused by channel ID, updating text in place rather than rebuilding the entire list each minute.
Vanilla JavaScriptDOM reuseConfiguration mapping
XMLTV guide pipeline
A custom C# / ASP.NET Core API loads XMLTV schedules into a channel index and serves a compact JSON summary of current and upcoming programmes. The app polls that summary every minute and caches playlist metadata for 30 minutes. Schedule times are normalised to Unix timestamps; channel aliases link different source names. The +1 channels use their own delayed streams and API listings.
ASP.NET CoreXMLTVREST / JSONBatch requests
Streaming lifecycle
HTML5 video uses native HLS playback in supported browsers, Video.js for other HLS playback and dash.js for MPEG-DASH, with player libraries loaded on demand. Channel changes invalidate previous callbacks so late events cannot interrupt a newer stream. Local players are disposed when replaced; AirPlay channel changes reuse the native video element to preserve the connection. The DASH path also supports configuring a Widevine licence server through an ASP.NET proxy.
HLSMPEG-DASHVideo.jsdash.js
Chromecast and AirPlay
Watch live TV on a compatible television using the Cast and AirPlay buttons beside the menu. Start a channel, then choose a device. The controls appear when supported by the browser and playback setup.
Chromecast sends the stream URL, channel name and logo to Google's Default Media Receiver. The TV plays the stream directly, while channel changes and Stop remain available in the PWA. Channels requiring the app's Widevine licence proxy are not currently supported over Cast.
AirPlay uses Safari's native video playback and device picker. Switching HLS channels keeps the same AirPlay connection. Use Stop AirPlay to stop the stream, or end AirPlay in the picker. A three-second grace period allows brief AirPlay route changes to recover before the app stops and unloads the video. Stop AirPlay works immediately; after a confirmed disconnect, select a channel again to watch on this device.
Google CastAirPlayLive TVDevice controls
Recovery and playback monitoring
Guide requests are shared while in flight, with exponential retry delays and the last successful listings retained in memory. Playback monitoring checks the media clock as well as buffering events. Advancing video cancels the stall timer; prolonged buffering shows a notice while allowing the player to recover. Startup failures and fatal playback errors follow a separate cleanup path.
Request deduplicationBackoffMedia events
Authentication and preview policy
C# ASP.NET handlers on IIS validate POSTed credentials against the shared user file and issue an encrypted, Secure, HttpOnly, SameSite login cookie valid for 30 days. It restores the server session after reopening the app; signing out clears it, and account-file changes invalidate it. The app checks session status to control sports visibility. TVNZ guest previews share a two-minute window and a 30-minute cooldown, persisted in localStorage across reloads and communicated between tabs. Signing in cancels the preview timer; signing out stops restricted playback. These browser controls demonstrate the access policy; they do not protect the upstream stream URLs.
ASP.NET sessionsHTTP cookieslocalStorageStorage events
Mobile layout and PWA caching
Dynamic viewport units, edge-to-edge layout and safe-area insets keep video full size while positioning controls around screen cutouts. Playback switches the theme colour to black. The menu offers Chrome’s install prompt and manual Chrome/Safari installation steps, hiding them in installed mode. A web app manifest supports installation, while a service worker revalidates static assets and falls back to saved copies when the network fails. Video, guide API and session requests bypass that static cache. The About sheet uses a native dialog; the account drawer manages keyboard focus.
Service workerCache StorageCSS safe areasNative dialog
Verification
Regression checks use the Node.js test runner and isolated JavaScript contexts to exercise guide mapping, retries, buffering, sessions, preview deadlines, Cast channel changes and AirPlay disconnect cleanup. Browser checks combine real HLS playback with simulated authentication responses to verify channel visibility, login/logout transitions and portrait/landscape layouts.
node:testVM contextsBrowser checks
Visit Better Media Hub ↗