live-cat-test
TypeScript icon, indicating that this package has built-in type declarations

0.2.4 • Public • Published

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({
    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({
  address,
  appKey,
  onPlay: () => {
    //do something
  },
})

Adjust bandwidth

launcher.changeBandwidth(
  8000, // start bitrate kbps
  10000, // max bitrate kbps
  5000, // min bitrate kbps
)
launcher.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])

Readme

Keywords

Package Sidebar

Install

npm i live-cat-test

Weekly Downloads

0

Version

0.2.4

License

MIT

Unpacked Size

526 kB

Total Files

107

Last publish

Collaborators

  • jim1874