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-vhs@latest"></script>

File

Click me

Browserify / Webpack

npm install --save swarmcloud-vhs

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

var P2pEngineVHS = require('swarmcloud-vhs');

If you are using ES6's import syntax:

import P2pEngineVHS from 'swarmcloud-vhs';

Usage

var engine;
var player = videojs('my_video', {
html5: {
vhs: {
overrideNative: true // Enable p2p if the platform supports Media Source Extensions
},
}
});
player.on('xhr-hooks-ready', () => {
if (engine) {
engine.destroy();
}
engine = new P2PEngineVHS(player, {
// trackerZone: 'hk', // if using Hongkong tracker
// trackerZone: 'us', // if using USA tracker
// token: YOUR_TOKEN
})
});
player.src(YOUR_PLAYLIST_URL)