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"></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
},videojs)
});
player.src(YOUR_PLAYLIST_URL)

File Explanation

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