Skip to main content
Version: 11.16.0

How to use THEOplayer feature modules

The Web SDK ships every feature as a separate JavaScript module, next to the classic theoplayer and theoplayer/chromeless entry points. Instead of importing the whole package at once, you can import the core player plus exactly the features your app needs. A bundler then only includes the modules you actually use, which reduces the download size of your app.

import * as THEOplayer from 'theoplayer/core';
import 'theoplayer/dash';

const element = document.querySelector('.theoplayer-container');
const player = new THEOplayer.Player(element, {
libraryLocation: '/url/to/node_modules/theoplayer/',
license: 'your_license_string',
});
Import before constructing a player

A feature registers itself when its module is imported, and the player reads the registry when it is constructed. Import every feature module before constructing your first player — statically, like above. A dynamic import() after the player was created is not supported.

Base modules​

Import nameRegistersWhat you get
theoplayer/core—The chromeless player, without any features.
theoplayer/uiuiThe player with the default UI (imports theoplayer/core itself). Also add the ui.css stylesheet.
theoplayerui + every feature of your package variantThe player with the default UI and all features of your package variant (backward compatible).
theoplayer/chromelessevery non-UI feature of your package variantThe chromeless player with all non-UI features of your package variant (backward compatible).

All four export the Player class and the player API; theoplayer and theoplayer/chromeless additionally re-export the named exports (cast, cache, MultiViewPlayer) of the feature modules they enable. Note that theoplayer/chromeless does not enable ui or the eight UI-plugin features, even when your package variant selects them — import theoplayer/ui and the UI-plugin modules explicitly in that case.

Feature modules​

Each module below registers the feature listed next to it in THEOplayer.features. Every module requires theoplayer/core or theoplayer/ui; modules listed under "Also imports" additionally need that module (it is imported automatically).

Import nameTHEOplayer.featuresAlso importsNamed exportsDescription
theoplayer/hlshlsHLS playback
theoplayer/dashdashMPEG-DASH playback
theoplayer/hesphespHESP (THEOlive) playback
theoplayer/millicastmillicastMillicast playback
theoplayer/lcevc-hlslcevchlsMPEG-5 LCEVC on top of HLS
theoplayer/lcevc-dashlcevcdashMPEG-5 LCEVC on top of DASH
theoplayer/hbbtvhbbtvHbbTV device support
theoplayer/chromecastchromecastcastChromecast sending
theoplayer/airplayairplayAirPlay sending
theoplayer/vrvr360° and VR playback
theoplayer/cachecachecacheDownloading and offline playback
theoplayer/adsadsClient-side advertising (CSAI)
theoplayer/theoadstheoadsOptiView Ads (server-guided ads)
theoplayer/google-daigoogle-daiGoogle DAI ad insertion
theoplayer/freewheelfreewheelFreeWheel ad scheduling
theoplayer/mediatailormediatailorAWS MediaTailor ad tracking
theoplayer/spotxspotxadsSpotX ad serving
theoplayer/moatmoatMoat ad analytics
theoplayer/streamonestreamoneStreamOne ad serving
theoplayer/uplynkuplynkUplynk/Verizon Media SSAI
theoplayer/youborayouboraYoubora analytics
theoplayer/mediamelonmediamelonMediaMelon analytics
theoplayer/agamaagamaAgama analytics
theoplayer/related-contentrelatedcontentuiRelated-content overlay
theoplayer/social-sharingsocialuiSocial sharing overlay
theoplayer/up-nextupnextuiUp-next countdown
theoplayer/context-menucontextmenuuiRight-click context menu
theoplayer/text-track-style-uitexttrackstyle-uiuiSubtitle styling menu
theoplayer/active-quality-labelactivequalitylabeluiQuality label on the control bar
theoplayer/upcoming-ad-notificationupcomingadnotificationui"Upcoming ad" notification
theoplayer/multiviewmultiviewuiMultiViewPlayerMulti-angle playback

Notes​

  • The theoplayer package (and every npm variant of it) ships all of these modules. Your package variant only decides which features theoplayer and theoplayer/chromeless enable by default; it does not limit which modules you can import.
  • theoplayer/uplynk also covers sources configured for the verizonmedia feature.
  • The eight UI-plugin modules (the rows whose "Also imports" column says ui) need theoplayer/ui and are not re-exported by theoplayer/chromeless — in a custom --features build without ui they are unavailable entirely.
  • theoplayer/cache can only cache the formats whose module is loaded: import theoplayer/hls and/or theoplayer/dash to cache those streams.
  • The type declarations of theoplayer/core still list cast and cache (and those of theoplayer/ui list MultiViewPlayer). At run time they are only defined when the corresponding feature module is imported.
  • Feature modules only change which code your app loads. The player configuration (license, libraryLocation, ...) is unchanged — libraryLocation still needs to point at the directory containing the library files so the workers can be loaded.
  • Modules whose code is shared with other modules are split automatically by your bundler; you never import shared chunks yourself.

Recipes​

Minimal chromeless DASH player (e.g. smart TV)​

import * as THEOplayer from 'theoplayer/core';
import 'theoplayer/dash';
import 'theoplayer/hbbtv'; // HbbTV devices only

const element = document.querySelector('.theoplayer-container');
const player = new THEOplayer.Player(element, {
libraryLocation: '/url/to/node_modules/theoplayer/',
license: 'your_license_string',
});

Player with the default UI and a plugin​

<link rel="stylesheet" href="/url/to/node_modules/theoplayer/ui.css" />
import * as THEOplayer from 'theoplayer/ui';
import 'theoplayer/hls';
import 'theoplayer/up-next';

const element = document.querySelector('.theoplayer-container');
const player = new THEOplayer.Player(element, {
libraryLocation: '/url/to/node_modules/theoplayer/',
license: 'your_license_string',
});

Caching for offline playback​

import * as THEOplayer from 'theoplayer/core';
import 'theoplayer/dash';
import { cache } from 'theoplayer/cache';

The cache object exposes the caching API (creating and starting caching tasks).

See also​