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.

Integrate to HTML5 Players

See Player Integration

Include

Script

<script src="https://cdn.jsdelivr.net/npm/swarmcloud-theoplayer@latest"></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',
ui: {
width: "512px",
height: "288px",
},
liveOffset: 30,
license: YOUR_THEOplayer_LICENSE_KEY,
});
var engine = new P2pEngineTheo({
// trackerZone: 'hk', // if using Hongkong tracker
// trackerZone: 'us', // if using USA tracker
// token: YOUR_TOKEN
});
engine.setPlayer(player);
player.source = {
sources: [{
src: 'YOUR_PLAYLIST_URL',
type: 'application/x-mpegURL'
}]
};