Nanobots Protecting Microbots

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

    0.4.5 • 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({
        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])

    Keywords

    Install

    npm i live-cat

    DownloadsWeekly Downloads

    266

    Version

    0.4.5

    License

    MIT

    Unpacked Size

    559 kB

    Total Files

    111

    Last publish

    Collaborators

    • jim1874
    • elyongwj
    • kitsch