Skip to main content

Player Drivers

Choose which playback drivers the player may use, in what order, and how to switch between them at runtime.

This page describes the drivers option of requestPlayer in @video/video-client-core: the driver ids the Native Frame player can use, the order it tries them in, the options each driver accepts, and how to switch drivers at runtime. It does not cover creating a player or wiring it into a page — see View a Stream for setup and Player API Reference for the player object itself.

Drivers​

A driver is the playback engine behind the player. The player tries the configured drivers in order and fails over to the next one when a driver cannot play the current media.

Driver idPlaysPurpose and constraints
webrtcWebRTC (MediaSoup)Lowest latency. The only driver that joins the call: player.call is populated only while this driver is active. Switches renditions without pausing.
native-hlsHLS through the browser's built-in supportReports itself as supported only on Safari and iOS. No JavaScript playback engine.
hlsjsHLS through the hls.js libraryRefused on Safari, where the player uses native-hls instead. Needs the optional peer package hls.js.
flvhttpFLV over HTTP through mpegts.jsNeeds the optional peer package mpegts.js.
media-streamAn existing MediaStreamPlays a MediaStream you already hold, with no manifest — for example a call participant's stream handed to the player.

HLS is one protocol served by two drivers: native-hls uses the browser's own engine, and hlsjs uses a JavaScript engine. See Streaming Protocols for how the protocols compare.

Peer packages​

Two drivers depend on a package that is not bundled with @video/video-client-core. Install the one your chosen driver needs; View a Stream covers installation.

Driver idPeer packageVersion range
hlsjshls.js^1.4.14
flvhttpmpegts.js^1.7.3
Call handover

A stream you join through a call reaches the player only through the webrtc driver, because that is the only driver that populates player.call. See Private viewer for a worked call example.

Set drivers at request time​

Pass drivers in the options object of requestPlayer. Each entry is either a bare driver id or an object that carries the id and that driver's options; the two forms mix freely in one array. The input type is PlayerDriverOptionsIn, and the player exposes the resolved list as PlayerDriverOptionsOut.

String form​

const player = await vc.requestPlayer(manifestUrl, { drivers: ["webrtc", "native-hls", "hlsjs"] });

Object form​

const player = await vc.requestPlayer(manifestUrl, {
drivers: ["webrtc", { id: "hlsjs", hlsjsConfig: { debug: true } }, "native-hls", { id: "flvhttp" }],
});

Rules​

  • Order is priority: the player tries the first entry first.
  • Duplicate ids are rejected. The validation error reads "duplicates are not allowed".
  • A driver that reports itself as unsupported, or that fails with a fatal error, rotates to the next entry immediately.
  • Each entry's timeout bounds how long that driver may take to start.
  • When every entry is exhausted, the player emits noDrivers. The noDrivers and drivers event rows are on the Player API Reference.

Default order​

When you omit drivers, the player uses this order:

drivers: ["webrtc", "native-hls", "hlsjs", "flvhttp", "media-stream"]

Driver options​

Use the object form to pass options to a driver. The common options apply to every driver; the per-driver tables list what each driver adds.

Options for every driver​

OptionTypeDefaultDescription
timeoutnumber (milliseconds)10000Time allowed for the driver to start. Minimum 1000, maximum 30000.
fullScreenHandlers{ enter(): Promise<void>, exit(): Promise<void> }noneOptional handlers the player calls when entering and leaving fullscreen.

webrtc​

OptionTypeDefaultDescription
joinLoadbalancerFallbackbooleantrueFall back to the load balancer if the direct connection fails.

hlsjs​

OptionTypeDefaultDescription
hlsjsConfigobject{}Passed through to hls.js. Accepts hls.js configuration keys.

The player merges hlsjsConfig over its own defaults: debug: false, enableWorker: true, lowLatencyMode: true, backBufferLength: 90, and maxAudioFramesDrift: 50.

native-hls, flvhttp, media-stream​

These drivers accept the common options only.

Choose an order​

The default order, webrtc then native-hls, hlsjs, flvhttp, and media-stream, is what the SDK ships and is the right starting point for most integrations. Reorder or trim it when one of the following factors matters more than lowest latency.

Audience size​

Every webrtc viewer holds a per-viewer session. For a large audience, the HLS drivers (native-hls and hlsjs) fan out more cheaply, so consider placing them ahead of webrtc when reach matters more than latency.

Latency target​

Keep webrtc first when you need the lowest latency the platform offers. The other drivers sit in higher latency tiers.

Devices​

The default order already handles Safari and iOS: native-hls comes before hlsjs, and hlsjs declines to run on those devices. This only matters if you set a custom order. If your audience is largely on those devices, list native-hls ahead of hlsjs so the player does not spend a failover step on a driver that will decline.

Browsers​

The hlsjs and flvhttp drivers only work in a browser where you have installed their peer package. If you leave a peer package out, drop its driver from the list so the player does not spend a failover step on a driver that cannot run. The native-hls driver has no such dependency, but only reports itself supported on Safari and iOS.

See Latency for the latency tiers and Streaming Protocols for the protocol comparison.

Switch drivers at runtime​

await player.switchDriver("webrtc");

switchDriver(driver: string): Promise<void> switches to a specific driver by id and resolves once the change has been applied. nextDriver(): Promise<void> advances to the next entry in the configured order. The drivers getter returns the current order as an array of ids. The method, property, and event rows for these members are on the Player API Reference.

Version notes​

Deprecated alias

Deprecated: the players option is a deprecated alias for drivers; it is still accepted, logs [deprecated] players is deprecated: use 'driver' instead when the device debug flag is on, and is rewritten onto drivers. Use drivers in new code.