Player features
This page shows how to use each nanoStream Player feature in practice, with the config you need. For the full list of keys and defaults, see the Player configuration reference.
MOQ (Media over QUIC)
MOQ (Media over QUIC) is the player's primary playback technology since version 5.0. It runs over QUIC with WebTransport and WebCodecs and holds up better on unstable or changing networks. It is on by default.
playback: {
enableMediaOverQuic: true, // default: true
enableQuicConnectionProbe: true // default: true
}
- If the browser supports MOQ, the player uses it. If not, or if the connection probe fails, it falls back to H5Live over WebSocket/MSE on its own.
- With
source.group,bintu.streamidordefaults.service: "bintu", nothing else is needed. With custom server URLs, seth5live.server.webtransporton each entry. - MOQ renders to a
<canvas>, not a<video>element. If your code depends on the video element, setenableMediaOverQuic: false. - nanoStream Analytics reports MOQ playback separately under
/v2/moq/*. See Analytics API.
Browser support is listed on Playback technologies.
Fast start
Fast start shortens the time to first frame. It is on by default in v5.
playback: { faststart: true }
It applies whenever the player goes from paused to playing: the play button, setup() with autoplay, play(), and switchStream() / updateSource() with forcePlay.
With ABR, start on a medium or lower rendition (group.startQuality: "medium" or a middle startIndex). Fast start on a high-bitrate rendition can stall on slow connections.
Latency control
playback.latencyControlMode decides how tightly the player holds to the live edge. All three modes are low latency.
| Value | Behaviour |
|---|---|
balancedadaptive | Default in v5. Adapts to stream and network conditions; low latency with smooth playback. |
fastadaptive | Tracks the live edge most closely. On iOS it falls back to balancedadaptive. |
classic | Buffer-based, tunable with tweaks.buffer |
Details and guidance: Latency & latency control modes.
Autoplay
Browsers only allow autoplay with muted audio, or after a user interaction. Configure the player to try with sound first and fall back to muted:
playback: {
autoplay: true,
automute: true,
muted: false
}
For guaranteed silent autoplay, set muted: true.
On iOS in Low Power Mode, playback always needs a user gesture, even muted. The player raises error 1005. Don't retry automatically; show a "tap to play" button and call player.play() from its click handler.
For native apps, autoplay also needs WebView settings. See Supported browsers & devices.
Reconnect
The player reconnects by itself when the network connection fails at start or breaks during playback. It's on by default.
playback: {
reconnect: {
minDelay: 2, // seconds, minimum 1
maxDelay: 10, // seconds
delaySteps: 10, // steps until maxDelay
maxRetries: 10 // 0 disables reconnect
}
}
- During a reconnect, the player fires
onPausewith reasonreconnectionimminent, notonError. - When
maxRetriesis used up, it firesonErrorand thenonPause. - Reconnect covers network breaks only. A stream that stops at the source, or a pause with a reason other than
normal, isn't reconnected.
Timeouts
| Key | Default | Range | On expiry |
|---|---|---|---|
playback.timeouts.connecting | 5 s | 5–30 s | Error 4106, reason connectionclose |
playback.timeouts.loading | 20 s | 10–60 s | Error 2001, reason streamnotfound |
playback.timeouts.buffering | 20 s | 10–60 s | Error 2002, reason buffer |
Keep connecting at or below loading. Change these values with care: shorter timeouts give up sooner on slow networks.
Media error recovery
For some media errors the player recovers by itself and keeps playing: 1008, 3003, 3005, 3100 and 3101. Each recovery fires onWarning, for example Recovering from media error 3003, recovery 1/3 within the last 60 seconds (12 total).
playback: { mediaErrorRecoveries: 3 } // per 60 seconds; 0 disables
If more recoveries happen within 60 seconds than allowed, the player raises the error and pauses with reason playbackerror. The default of 3 is recommended.
Adaptive Bitrate Streaming and stream switching
This video walks through multi-bitrate streams and ABR on the nanocosmos platform:
Automatic ABR
With a stream group, ABR works without configuration. With source.entries, list the renditions highest bitrate first and set a rule:
source: {
defaults: { service: "bintu" },
entries: [
{ index: 0, label: "high", h5live: { rtmp: { streamname: "XXXXX-HIGH1" } } },
{ index: 1, label: "medium", h5live: { rtmp: { streamname: "XXXXX-MED01" } } },
{ index: 2, label: "low", h5live: { rtmp: { streamname: "XXXXX-LOW01" } } }
],
startIndex: 1,
options: {
adaption: { rule: "deviationOfMean2" }
}
}
When playback doesn't start on the highest rendition, the player switches up step by step at start until it finds the right quality for the bandwidth.
| Option | Use |
|---|---|
options.adaption.downStep | Minimum quality steps per down-switch |
options.adaption.omitRenditions | Exclude renditions from ABR, for example ["high"] on mobile. Manual switching still reaches them. |
Manual quality selection
switchStream(index) switches to another entry of the current source, for example from a quality menu:
player.switchStream(2).then(function (config) {
console.log("switch started");
}, function (error) {
console.log(error); // rejected if the index is out of range
});
A manual switch turns off ABR. To go back to "Auto", call setAdaption:
player.setAdaption({ rule: "deviationOfMean2" });
Listen to onSwitchStreamInit, then one of onSwitchStreamSuccess, onSwitchStreamFail or onSwitchStreamAbort. An onStreamInfo event signals the first frame of the new stream.
Play a different stream
updateSource(source) replaces the whole source in the running player, without rebuilding it. Use it to change channels, tables or events. It takes one argument shaped like config.source, including options.
player.updateSource({
group: { id: "<NEW_GROUP_ID>", security: { jwtoken: "<YOUR_JWT>" } }
}).then(function (config) {
console.log("update started");
}, function (error) {
console.log(error);
});
The new source replaces the old one even if the update fails. Events: onUpdateSourceInit, then onUpdateSourceSuccess, onUpdateSourceFail or onUpdateSourceAbort. Aborts have a reason: equalsource, superseded or frequency.
For server-driven camera cuts across all viewers, use Multi-Camera instead.
Fullscreen
player.requestFullscreen()
.then(function () { console.log("fullscreen"); })
.catch(function (err) { console.log("rejected: " + err.reason); }); // "denied" or "disabled"
player.exitFullscreen()
.catch(function (err) { console.log("rejected: " + err.reason); });
Browsers only allow fullscreen from a user interaction such as a click. Always handle the rejected promise. onFullscreenChange reports changes in event.data.entered. To hide the built-in button, set style.fullScreenControl: false. On iOS, give custom overlays a z-index above 1.
iOS silent switch and microphone pages
By default the player sets the iOS audio session to playback during setup, so audio is audible with the silent switch on (playback.manageAudioSessionType: true, since 5.0.11).
If your page also captures the microphone (WebRTC, getUserMedia, for example a co-host or talkback), set the session type yourself before calling getUserMedia. The player leaves play-and-record untouched:
if (navigator.audioSession) {
navigator.audioSession.type = "play-and-record";
}
Set manageAudioSessionType: false if your app manages the session type completely on its own.
Custom domains
To serve playback, API and metrics from your own domains, set one root domain:
source: { general: { baseDomain: "example.com" } }
// → server play.example.com, API https://api.example.com, metrics telemetry.example.com
source.general.serverDomain, source.group.apiurl and metrics.serverDomain set each value individually and take precedence over baseDomain. Don't combine both styles unless you need to. For delivery regions and firewall allowlists, see Global delivery & nanoStream CDN.
UI customization
The player view has three layers you can style: the center view with the play button, the control bar, and the poster or background colour behind them.

Colours and controls
style: {
symbolColor: "#ed7d0e",
controlBarColor: "rgba(0,0,0,0.8)",
buttonAnimation: false,
buttonCursor: "default",
poster: "https://example.com/poster.png",
backgroundColor: "black"
}
Colours accept CSS keywords, hex (with or without alpha), rgb/rgba and hsl/hsla. To build your own controls, set style.controls: false and give your overlay a z-index above 10.
Responsive player
Set width and height to "auto" and size the container with CSS:
<div id="playerDiv" style="width:100%; padding-bottom:56.25%"></div>
| Aspect ratio | padding-bottom |
|---|---|
| 16:9 | 56.25% |
| 4:3 | 75% |
| 1:1 | 100% |
Scaling
style.scaling | Effect |
|---|---|
letterbox (default) | Keeps the aspect ratio and adds bars |
crop | Keeps the aspect ratio and fills the frame by cutting edges |
fill | Fills the frame and may distort the image |
No player UI
style.view: false removes all player UI and leaves the plain media element: <video> for H5Live, <canvas> for MOQ. Style the container (#playerDiv), not the inner element; the player manages its size.
Audio-only
style.audioPlayer: true renders a compact audio player. style.displayAudioOnly: true shows an audio symbol when a stream has no video.
Video access and snapshots
onActiveVideoElementChange gives you the active <video> element (H5Live playback), for example to draw frames on a canvas or take a snapshot. Treat the element as read-only.
var activeVideo = null;
var config = {
// source, ...
playback: { crossOrigin: "anonymous" }, // required to read pixels
events: {
onActiveVideoElementChange: function (e) { activeVideo = e.data.activeVideoElement; },
onDestroy: function () { activeVideo = null; }
}
};
function takeSnapshot(canvas) {
if (!activeVideo) return null;
canvas.width = activeVideo.clientWidth;
canvas.height = activeVideo.clientHeight;
canvas.getContext("2d").drawImage(activeVideo, 0, 0, canvas.width, canvas.height);
return canvas.toDataURL("image/jpeg", 1);
}
On iOS there are two video elements; the event tells you which one is active. Canvas drawing from MSE isn't supported in Safari on macOS and iPadOS desktop mode. MOQ playback renders to a canvas and doesn't use a video element.
Metadata
Set playback.metadata: true to receive in-stream metadata through onMetaData (data.handlerName, data.message, data.streamTime). See Stream tags & metadata.
iframe embedding
Embedding the player directly in your page is the best option for most cases. Use an iframe only if your setup needs it, and always add allowfullscreen:
<iframe src="https://yourdomain.com/playerpage.html"
width="640" height="360" scrolling="no" frameborder="0"
allow="autoplay; fullscreen" allowfullscreen></iframe>
For a hosted, ready-made iframe player, see Embed the player.
Live replay
The Live + Replay player plays the live stream and its growing recording in one frame: viewers scrub back during the event and return to the live edge. See Live replay.
Next steps
- Player configuration reference: every key and default
- Events & error codes: handle errors and build retry logic
- Supported browsers & devices: iOS, Android and WebView notes
- Multi-Player: several streams on one page