Skip to main content

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

Demo Running Guide

1、Download demo

2、Installation dependency

pnpm install

3、Installation depends on 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


const hls = new Hls({});

const APP_ID = ""; // TikCDN APPID

const HlsWithP2P = HlsJsP2PEngine.injectMixin(Hls);
const hls = new HlsWithP2P({
p2p: {
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, ignore none
// gatewayUrl: 'https://HOST:PORT/tikcdn/api/v1/gateway'
},
onHlsJsCreated(hls) {
// Listen for hls related callbacks
},
},
});

开始播放并加速

const streamUrl = ''; // Your live stream address
const videoDom = document.getElementById('video-renderer');

// Binding container
hls.attachMedia(videoDom);
// Play the video feed and start speeding up ⏩
hls.loadSource(streamUrl);

Release engine

hls.destroy();