Skip to main content

Usage

Register Domain

Register your domain to activate P2P service.

tip

Localhost is always whitelisted. This means that you do not have to configure anything to perform tests locally.

Demo

See Player Demo

Include

Script

<script src="https://cdn.jsdelivr.net/npm/@swarmcloud/theoplayer"></script>

File

Click me

Browserify / Webpack

npm install --save @swarmcloud/theoplayer

To include p2p engine you need to require it in the player module:

var P2pEngineTheo = require('@swarmcloud/theoplayer');

If you are using ES6's import syntax:

import P2pEngineTheo from '@swarmcloud/theoplayer';

Usage

var element = document.querySelector(".theoplayer-container");
var player = new THEOplayer.Player(element, {
libraryLocation: '/path/to/your-theoplayer-folder',
liveOffset: 30,
license: YOUR_THEOplayer_LICENSE_KEY,
});
var engine = new P2pEngineTheo(player, {
// trackerZone: 'hk', // if using Hongkong tracker
// trackerZone: 'us', // if using USA tracker
// token: YOUR_TOKEN
});
player.source = {
sources: [{
src: YOUR_PLAYLIST_URL,
}]
};

File Explanation

@swarmcloud/theoplayer/
├── theoplayer-p2p-engine.min.d.ts # Typescript type information
├── theoplayer-p2p-engine.min.js # P2pEngine that supports both Dash and Hls
└── theoplayer-p2p-engine.hls.min.js # P2pEngine that supports Hls only
└── theoplayer-p2p-engine.dash.min.js # P2pEngine that supports Dash only