HLS & DASH Streaming
On WebGL, ProperVideoPlayer supports HLS and DASH sources through the browser's media
pipeline. URLs ending in .m3u8 or .mpd are detected automatically.
Open a stream#
player.Open("https://cdn.example.com/live/master.m3u8"); // HLS
player.Open("https://cdn.example.com/vod/manifest.mpd"); // DASH
// Specify the type when the URL has no recognizable extension.
player.Open(tokenUrl, playWhenReady: true, sourceType: VideoSourceType.Hls);
Streaming engines#
HLS uses the browser's native HLS implementation when one is available and no custom request headers are set.
Otherwise, the player uses hls.js. DASH uses
dash.js. Both JavaScript engines attach to the same
hidden <video> element used for progressive playback, so the component API, events, diagnostics,
and watchdog remain available.
hls.js and dash.js are not included in the package. On first use, the player loads pinned versions from jsDelivr. To self-host them, include the libraries in the WebGL template before the Unity loader:
<script src="lib/hls.min.js"></script>
<script src="lib/dash.all.min.js"></script>
If window.Hls or window.dashjs already exists, the player uses it. You can also change
the library URLs before opening the first stream:
WebGLVideoBridge.ConfigureStreamingLibraries(
hlsUrl: "https://cdn.example.com/lib/hls.min.js",
dashUrl: "https://cdn.example.com/lib/dash.all.min.js");
Operational considerations#
- CORS: manifests, segments, keys, and the final media response must permit requests from the WebGL application's origin. See Autoplay & CORS.
- Live duration: a non-finite browser duration is exposed as
0, while other live streams may expose a changing duration or seekable window. Build live seek controls from theSeekabletime ranges rather than assuming that every live source has the same duration semantics. - Errors: fatal streaming-engine errors invoke
OnErrorwith an HLS or DASH error description. The low-level bridge reports error code100for these errors. - Authentication: request headers and credentials can be applied to streaming requests. See Token-Authenticated Streams.
- Encryption: standard AES-128 HLS is handled by the selected HLS implementation, and hls.js key requests use the configured headers and credentials. EME-based DRM is not supported.
Non-WebGL platforms#
Outside WebGL, the component passes the URL to Unity's VideoPlayer. The package reports HLS support
on iOS, tvOS, macOS, and Android; it reports HLS as unsupported on Windows and DASH as unsupported on all
non-WebGL targets. Check support before presenting a streaming source:
var type = ProperVideoPlayer.DetectSourceType(url);
if (ProperVideoPlayer.IsStreamingSupported(type))
player.Open(url);
else
notice.Show("This stream requires a supported platform.");
Public test streams#
| Type | URL |
|---|---|
| HLS | https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.ism/.m3u8 |
| DASH | https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd |