0.1.0 • Published 2 years ago

live-cat-kd v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

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])