Documentation

Working With Electron

Scope of support

Building desktop apps for Windows, macOS and Linux can be an essential part of your OTT strategy. Those apps can be published on the Windows Store or Mac App Store and this can significantly extend your reach. You can easely use Radiant Media Player in an Electron-based desktop app to achieve those goals.

Electron is a framework for creating native desktop applications with web technologies like JavaScript, HTML, and CSS. It runs on a local node.js server, uses Chromium browser as a basis for rendering web content and provides a complete set of API to access native desktop functionalities. Electron is an already popular and reliable framework and is used to build major desktop apps like Visual Studio Code or Skype.

In terms of concept Electron works very similarly to Cordova, the main difference is that with Cordova you can build iOS and Android mobile apps and with Electron you can build desktop apps for Windows, macOS and Linux.

Building Electron-based desktop apps with Radiant Media Player is only available to PLATFORM Edition customers.

Supported environments

Here are the requirements for using Radiant Media Player with Electron to build desktop apps:

  • Electron 15+

The list of supported OS for Electron 15+ can be found here and includes Windows 7+, macOS 10.12+, Ubuntu 14.04+, Fedora 24+ and Debian 8+.

Radiant Media Player could work with previous versions of Electron but they are untested.

Supported features

All player features available for the desktop web are generally available with Radiant Media Player used in an Electron-based desktop app. Below is a non-exhaustive list of features you can expect to be available or not:

Feature Support
HLS
MPEG-DASH
MP4/WebM Progressive download
HTML5 video ads (2)
VOD, Live & Low-latency streaming
Autoplay with sound
Widevine DRM (3)
Google Cast (4)
Offline download & playback (5)

Video ads support in Electron-based apps

We do support using video ads in a Electron app. While it is technically possible to use Google IMA, our VAST parser rmp-vast is the preferred solution as Google does not officially support Electron platform. The VAST parser can be selected with player setting adParser set to 'rmp-vast'.

DRM support in Electron-based apps

See our working with Electron and DASH with Widevine DRM guide.

Offline playback of media content in Electron-based apps

We support download, storage and playback of offline content with DASH or fmp4-HLS streaming within an Electron-based apps. See our offline storage & playback docs.

Unsupported features:

  • Offline DRM licenses

Offline player starts are saved locally and push to our logging servers when an Internet connection becomes available.

Google Cast support in Electron-based apps

Since Chromium does not support the Google Cast API out of the box, we do not provide support for Google Cast in Electron-based apps. An unofficial Google Cast API wrapper exists and this may be helpful to implement Google Cast support in an Electron-based app outside of Radiant Media Player but this would fall outside our scope of support.

Walk-through using Radiant Media Player in an Electron based desktop app

We will use the electron-quick-start sample app to start with.

Once the electron-quick-start sample app is installed, we can install Radiant Media Player. While you could use our cloud player, we will use self-hosting for this walk-through to easily allow for offline playback case scenario. The structure of the electron-quick-start sample app should look like:

  • media/ - optional (you need to add this folder in your Electron project), here we could store our local/offline media content like MP4, HLS video or images
  • rmp/ - required if using self-hosting (you need to add this folder in your Electron project) - those are Radiant Media Player self-hosted files that can be downloaded in our back-end
  • index.html

Other folders and files are likely to be present but the above are those we need to focus on for now.

Now we will modify our index.html file to add Radiant Media Player:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
  <!-- Required Content-Security-Policy (CSP) - this is a loose example -->
  <meta http-equiv="Content-Security-Policy" content="default-src * blob: http: https: file: data: 'unsafe-inline' 'unsafe-eval';">
  <!-- Optional - including bootstrap CSS for nicer rendering -->
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css">
  <title>Hello RMP and Electron</title>
</head>

<body>
  <h1>Hello RMP and Electron</h1>
  <p>We are using Node.js <span id="node-version"></span>,
    Chromium <span id="chrome-version"></span>,
    and Electron <span id="electron-version"></span>.</p>
  <p>Here comes our player container</p>
  <div id="rmp"></div>
  <!-- Include player library -->
  <script src="./rmp/dist/rmp.min.js"></script>
  <script>
    // Our player settings
    const src = {
      // Here we load an online HLS resource
      hls: 'https://your-hls-url.m3u8'
    };
    const settings = {
      licenseKey: 'your-license-key',
      src: src,
      width: 640,
      height: 360,
      // Referencing required self-hosted files
      pathToRmpFiles: './rmp/', 
      // if we need ads
      // ads: true,
      // rmp-vast is the preferred solution in Electron apps to display ads
      // adParser: 'rmp-vast',
      // adTagUrl: 'https://www.radiantmediaplayer.com/vast/tags/inline-linear.xml'
    };
    const rmp = new RadiantMP('rmp');
    rmp.init(settings);
  </script>
</body>
</html>

Content-Security-Policy meta tag: before packaging an electron app for production you should review the security docs from Electron and notably the Content Security Policy guidelines. In the above example we have included a loose declaration for the CSP meta tag:

<meta http-equiv="Content-Security-Policy" content="default-src * blob: http: https: file: data: 'unsafe-inline' 'unsafe-eval';">

The blob: part is required for Media Source Extensions streaming. The file: part is required to load local resources. The data: part is required to load some internal player resources (base64 splash poster).

For local/offline playback of media resources we shall simply referenced our content from the media/ folder

<script>
  // Our player settings
  const src = {
    // Here we load an local/offline HLS resource
    hls: './media/hls/playlist.m3u8',
    // We could also load a MP4 file (optional)
    mp4 : [
      './media/mp4/content.mp4'
    ]
  };
  const settings = {
    licenseKey: 'your-license-key',
    src: src,
    width: 640,
    height: 360,
    // Referencing required self-hosted files
    pathToRmpFiles: './rmp/', 
    // Here we load our local/offline poster
    contentMetadata: {
      poster: [
        './media/images/poster-rmp-demo.jpg'
      ]
    }
  };
  const rmp = new RadiantMP('rmp');
  rmp.init(settings);
</script>

App allowlisting (PLATFORM Edition)

Refer to our documentation for PLATFORM Edition allowlisting and denylisting.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License.

©2015-2024 Radiant Media Player. All Rights Reserved.