MCPcopy Index your code
hub / github.com/canalplus/rx-player

github.com/canalplus/rx-player @v4.5.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v4.5.0 ↗ · + Follow
4,262 symbols 12,151 edges 1,069 files 1,668 documented · 39%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

RxPlayer's logo RxPlayer's logo

📖 API documentation - Demo - 🎓 Getting Started - 🔧 Contributing

The RxPlayer is a library implementing a DASH and Microsoft Smooth Streaming media player on a browser, by relying on the HTML5 Media Source Extensions and Encrypted Media extensions browser APIs.

This library only implements the core, non-UI part of a media player - you provide the interface while it handles the streaming. See our demo page for an example implementation.

Initially built for Canal+'s complex requirements across diverse devices, it prioritizes configurability and integration flexibility.


The RxPlayer can be seen as the "engine" providing adaptive streaming capabilities to an application:

  • Beyond DASH and Smooth Streaming support (and HLS on devices with native support like Safari), it handles complex scenarios like multiple DRM keys, fallback mechanisms for undecipherable or undecodable qualities, most subtitle formats and advanced heuristics to keep the playback going.

  • Multi-threaded architecture: core logic can be offloaded to a separate thread, keeping the player from blocking your application and vice-versa.

  • Production-tested across a wide device range: from low-end set-top boxes to high-end computers, with optimizations for constrained environments.

  • Highly configurable with a well-documented API: player behavior can be controlled at a granular level.

How to use it?

The fastest way to use the player directly in your code is to add this repository as a dependency.

You can do it via npm or yarn:

# when using npm:
npm install --save rx-player

# or, when using yarn instead:
yarn add rx-player

You can then directly import and use the RxPlayer in your code:

import RxPlayer from "rx-player";

const player = new RxPlayer({
  videoElement: document.querySelector("video"),
});

// play a video
player.loadVideo({
  url: "http://vm2.dashif.org/livesim-dev/segtimeline_1/testpic_6s/Manifest.mpd",
  transport: "dash",
  autoPlay: true,
});

We've also written short tutorials to help you familiarize with the RxPlayer API:

To be able to play with the player without needing to perform any setup we also created multiple live-editable demos:

Minimal Builds

To reduce the size of the final code, you might also want to import a minimal version of the player and only import the features you need. This is documented here :

For example, to play encrypted DASH contents, you could just write:

import RxPlayer from "rx-player/minimal";
import { DASH, EME } from "rx-player/features";

// Allow to play encrypted DASH contents
RxPlayer.addFeatures([DASH, EME]);

API

We documented the API in every little detail in the API documentation.

You can also refer to the documentation of our previous versions here

These documentation pages are automatically generated from the content of the doc/api directory in this repository.

Demo

You can view our online Demo, built from our last version, here.

This demo is a small application written in React demonstrating a simple usage of the player.

Demo pages for our previous versions are also available here.

Contribute

After cloning our repo, you should first install our dependencies via npm:

npm install

You can then run the list script to see the different scripts provided to test your modifications, run a demo locally etc.:

npm run list

Details on how to contribute is written in the CONTRIBUTING.md file at the root of this repository.

Features

Key features:

  • live and VoD DASH (including low-latency) / Smooth / HLS / Downloaded contents / MP4 / WebM* contents and more.

  • advanced encryption configuration: multiple keys in a single or separate licenses for a given content, automatic fallbacks on undecipherable contents, persistent licenses, complex MediaKeySystemConfiguration.

  • TTML, WebVTT, SAMI and SRT subtitles.

  • multi-threading support.

  • extensive APIs: audio-only, video track selection, manual garbage collection of segments, Peer-To-Peer integration, quality filtering...

  • adaptive streaming algorithms: both a network-based for quick start-up and buffer-based to provide the best quality possible.

  • complex segment scheduling logic: prioritizing closer media segments while making sure that the bandwidth usage is always optimal and the rebuffering risks always low.

  • heuristics to ensure playback stays smooth, the RxPlayer monitors playback and take actions if the current device has issues while decoding the stream.

  • optional WebAssembly-based MPD parser for DASH contents (for very large Manifests).

* In "directfile" mode, on compatible browsers

Extension points exported contracts — how you extend this code

ReportableAttribute (Interface)
Trait implemented for values that can be "reported" as an attribute to the JS-side. Reportable values can be sent to Ja [7 …
src/parsers/manifest/dash/wasm-parser/rs/reportable.rs
IMediaKeys (Interface)
(no doc) [9 implementers]
src/compat/browser_compatibility_types.ts
IRepresentationIndex (Interface)
(no doc) [16 implementers]
src/manifest/classes/representation_index/types.ts
ISourceBufferInterface (Interface)
(no doc) [4 implementers]
src/mse/types.ts
ITextDisplayerInterface (Interface)
(no doc) [4 implementers]
src/core/segment_sinks/implementations/text/text_segment_sink.ts
ITextDisplayer (Interface)
(no doc) [4 implementers]
src/main_thread/text_displayer/types.ts
IEventEmitter (Interface)
(no doc) [3 implementers]
src/utils/event_emitter.ts
IReadOnlyPlaybackObserver (Interface)
(no doc) [2 implementers]
src/playback_observer/types.ts

Core symbols most depended-on inside this repo

isNullOrUndefined
called by 366
src/utils/is_null_or_undefined.ts
addEventListener
called by 343
src/utils/event_emitter.ts
loadVideo
called by 275
src/main_thread/api/public_api.ts
error
called by 209
src/core/stream/representation/types.ts
trigger
called by 204
src/utils/reference.ts
waitForLoadedStateAfterLoadVideo
called by 188
tests/utils/waitForPlayerState.js
checkAfterSleepWithBackoff
called by 171
tests/utils/checkAfterSleepWithBackoff.js
getPosition
called by 164
src/main_thread/api/public_api.ts

Shape

Function 1,972
Method 1,310
Interface 641
Class 307
Enum 32

Languages

TypeScript99%
Rust1%

Modules by API surface

src/main_thread/api/public_api.ts123 symbols
src/main_thread/tracks_store/tracks_store.ts61 symbols
src/compat/browser_compatibility_types.ts54 symbols
src/public_types.ts47 symbols
src/main_thread/decrypt/__tests__/__global__/utils.ts43 symbols
src/main_thread/tracks_store/media_element_tracks_store.ts42 symbols
src/experimental/tools/DummyMediaElement/eme.ts42 symbols
src/core/types.ts42 symbols
src/playback_observer/media_element_playback_observer.ts37 symbols
tests/performance/run.mjs35 symbols
demo/scripts/modules/player/index.ts34 symbols
src/core/entry/core_entry.ts33 symbols

For agents

$ claude mcp add rx-player \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact