Skip to main content
Every source URL from /movie and /tv is either an HLS stream (.m3u8) or an MP4 file — your player code must handle both. HLS goes through HLS.js; MP4 sets video.src directly. The detection logic is the same everywhere.
These integration examples connect to your self-hosted Vyla API instance. Replace http://localhost:7860 with your actual API URL when deploying to production.

Source Type Detection

This is the single utility everything below depends on. A URL is MP4 if the proxy path ends in .mp4 or the upstream served a video content-type that isn’t HLS.

Installation


How the Stream Works

/movie and /tv are Server-Sent Events — not JSON. Each response is a live stream of data: lines. Three event types arrive in sequence: Start playback on the first source event — don’t wait for done. Queue every subsequent source as a fallback.

Minimal HTML Player

Zero dependencies beyond HLS.js. Handles both HLS and MP4 correctly.

Source switching, fallback queue, subtitle tracks, quality selector. All source types handled.

React

useStream Hook

Handles SSE parsing, abort on unmount, and re-fetch on param change. Drop-in for any framework.

attachSource Utility

Centralises HLS vs MP4 detection so every component shares one path.

StreamPlayer Component

Full-featured player: auto-starts on first source, queues fallbacks, source switcher, quality selector, subtitle tracks. Works for movies and TV.

Episode Selector

Renders an episode list and mounts the player only when an episode is selected — no streams open until the user picks something.

Next.js App Router

Movie Page

TV Episode Page

Dynamic HLS.js Import (SSR-safe)

HLS.js accesses window and will crash during SSR. Either mark the component 'use client' (already done above) or use a dynamic import to exclude it from the server bundle entirely:
Never import hls.js at the top level of a file that can run on the server. Always use 'use client' or a dynamic import with ssr: false.

Vue 3


Android (Kotlin + ExoPlayer)

ExoPlayer handles both HLS and MP4 natively — just pass the URL and it auto-detects the type.
ExoPlayer resolves HLS and MP4 automatically from the Content-Type returned by the proxy. No manual type detection needed on Android.

iOS (Swift + AVPlayer)

AVPlayer handles both HLS and MP4 natively. Same SSE parsing, different player attachment.
AVPlayer resolves HLS via application/vnd.apple.mpegurl and MP4 via video/mp4 content-type returned by the proxy — no manual detection needed on iOS either.

Python (mpv)

For desktop apps or scripts. mpv handles HLS and MP4 natively via its own demuxer.