Quick start
TikCDN solution makes full use of idle terminal bandwidth resources, complements traditional CDN, and builds a cost-effective new generation of content distribution network. Developers can quickly integrate with their own applications through the concise interface in the SDK to achieve P2P acceleration on Web devices.
Precondition
- A browser that supports the 'ls.js' player
- Effective account] [TikCDN developers (https://console.tikcdn.cc)
Demo Running Guide
2、Installation dependency
pnpm install
3、Configuring Developer information
Change the APP_ID field in the src/constants.ts file and run it.
export const APP_ID = ""; // Replace with your app ID
4、running
pnpm dev --host
Fast integration
Initialization engine
import shaka from "shaka-player/dist/shaka-player.ui";
import { ShakaP2PEngine } from "@x2-tik-tracker/shaka";
const APP_ID = "";
ShakaP2PEngine.registerPlugins(shaka);
const shakaP2PEngineInit = new ShakaP2PEngine(
{
core: {
useSSL: true,
appId: APP_ID,
token: '',
trackerZone: 'cn', // cn cc
// Custom Gateway address - If a gateway address is set, the trackerZone configuration is invalid
// gatewayUrl: 'https://HOST:PORT/tikcdn/api/v1/gateway'
},
},
shaka,
);
Start playing and speed up
const videoDom = document.getElementById('video-renderer');
// Your shaka player example
const shakaPlayerInit = new shaka.Player();
// Binding container
await shakaPlayerInit.attach(videoElement);
const streamUrl = ''; // Your live stream address
shakaP2PEngineInit.bindShakaPlayer(shakaPlayerInit);
// Play the video feed and start speeding up
await shakaPlayerInit.loadSource(streamUrl);
Release engine
shakaPlayerInit.destroy();