canalplus / rx-player

DASH/Smooth HTML5 Video Player
https://developers.canal-plus.com/rx-player/
Apache License 2.0
870 stars 132 forks source link
dash eme hss html5 live-streaming mse player streaming video video-player video-streaming

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.


Originally designed to power Canal+ many applications, the RxPlayer is today used in production by several companies in multiple countries and runs on most devices where a browser can run: Computers, phones, set-top-boxes, smart TVs, game consoles and other peculiar environments are all supported and able to profit from its many features.

Its main goals are:

The RxPlayer has probably already all the features you want :)!

Even if that's not the case, we will be very pleased to exchange with you on it and look forward for external contributions.

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 it ES6 style:
import RxPlayer from "rx-player";

// same in CommonJS style:
// const RxPlayer = require("rx-player");

// instantiate it
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 details 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

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

Dependencies

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

npm install

Why a new player?

A need for an advanced media player

Canal+ Group is a media company with many advanced needs when it comes to media playback: it provides both live and VoD stream with multiple encryption requirements, supports a very large panel of devices and has many other specificities (like adult content restrictions, ad-insertion, Peer-To-Peer integration, low-latency live streaming...).

When the time came to switch from a plugin-based web player approach to an HTML5 one back in 2015, no media player had the key features we wanted, and including those needs into an already existing media player would not be straightforward either.

The R&D department of Canal+ Group thus started to work on a new featureful media-player: the RxPlayer. To both help and profit from the community, it also decided to share it to everyone under a permissive open-source licence.

Now, more than 8 years later, the RxPlayer continues to evolve at the same fast pace to include a lot of features and improvements you may not find in other media players. You can look at our API documentation, tutorials and our demo page (an RxPlayer instance is available in the console through the global player variable there) to see if it matches your need.

A featureful player

With the help of a carefully-crafted and well-documented architecture, we were able to quickly support avanced features when we - or the community - needed them. Amongst those:

* In "directfile" mode, on compatible browsers