live-cat-kd
v0.1.0
Published
ray-streaming launcher for 3dcat
Downloads
2
Readme
3DCAT RayStreaming Launcher
RayStreaming launcher
Quick start
import { Launcher } from 'live-cat'
const appKey = 'xxxxxxxxxxxxxxxxxxx'
const address = 'xxxxxxxxxxxxxxxxxxx'
const bootstrap = async () => {
const player = document.querySelector('body')
document.querySelector('body').style.width = '100vw'
document.querySelector('body').style.height = '100vh'
const launcher = new Launcher({
baseOptions: {
address,
appKey,
},
})
launcher.automata(player)
}
window.addEventListener('DOMContentLoaded', () => {
if (
navigator.userAgent.includes('miniProgram') ||
navigator.userAgent.includes('MicroMessenger')
) {
//NOTE: wechat environment started
document.addEventListener('WeixinJSBridgeReady', bootstrap)
} else {
bootstrap()
}
})
Play callback
// call when video element start to play
new Launcher({
baseOptions: {
address,
appKey,
},
extendOptions: {
onPlay: () => {
//do something
},
},
})
Adjust bandwidth
launcher.getConnection().changeBandwidth(
8000, // start bitrate kbps
10000, // max bitrate kbps
5000, // min bitrate kbps
)
launcher.getConnection().changeBandwidth(
10000, // medians bitrate kbps
)
Statistics
launcher.toggleStatistics()
window.setInterval(() => {
const { fps, bitrate, packetLossRate, latency, averageJitterBufferDelay } = launcher.report()
console.log(`
FPS: ${fps}
biterate: ${bitrate}kbps
latency: ${latency}ms
averageJitterBufferDelay: ${averageJitterBufferDelay}ms
packetLossRate: ${(packetLossRate * 100).toFixed(3)}%
`)
}, 1000)
ToggleFullscreen
launcher.toggleFullscreen()
Destory
launcher.destory([errMsg])