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
Include
Script
<script src="https://cdn.jsdelivr.net/npm/@swarmcloud/shaka"></script>
File
Browserify / Webpack
npm install --save @swarmcloud/shaka
To include cdnbye you need to require it in the player module:
var P2PEngineShaka = require('@swarmcloud/shaka');
If you are using ES6's import syntax:
import P2PEngineShaka from '@swarmcloud/shaka';
Usage
const player = new shaka.Player();
player.attach(video);
if (P2PEngineShaka.isSupported()) {
new P2PEngineShaka(player, {
// trackerZone: 'hk', // if using Hongkong tracker
// trackerZone: 'us', // if using USA tracker
// token: YOUR_TOKEN
},shaka);
}
player.load(play_url)
File Explanation
@swarmcloud/shaka/
├── shaka-p2p-engine.min.d.ts # Typescript type information
├── shaka-p2p-engine.min.js # P2pEngine that supports both Dash and Hls
└── shaka-p2p-engine.hls.min.js # P2pEngine that supports Hls only
└── shaka-p2p-engine.dash.min.js # P2pEngine that supports Dash only
Electron
CDNBye also supports Electron, you just need to register AppId and get a token from CDNBye console:
new P2PEngineShaka(player, {
token: YOUR_TOKEN,
appName: YOUR_APP_NAME, // 应用的名称
appId: YOUR_APP_ID, // 需要与控制台输入的保持一致
// Other p2pConfig options if applicable
});
Learn more here