0.1.0-beta.0 • Published 4 months ago

rbi-streaming v0.1.0-beta.0

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

rbi-streaming Launcher

rbi-streaming launcher

Quick start

import { Launcher } from 'rbi-streaming'

const address = 'xxxxxx'
const replaceWs = 'xxxxxx'
const appKey = 'xxxxxxx'
let appSecret
let launcher

async function bootstrap() {
  const baseOptionsType = {
    address,
    replaceWs,
    appKey,
    startType: 1,
  }

  const container = document.querySelector('body')
  document.querySelector('body').style.width = '100%'
  document.querySelector('body').style.height = '100%'

  const uiOptions = {
    onPlay: () => {
      console.log('出现了有效画面')
      //web端->应用
      launcher.launcherBase.connection.emitUIInteraction('发给应用的数据').then((res) => {
        console.log(res ? '发送成功' : '发送失败')
      })
    },
  }
  launcher = new Launcher(baseOptionsType, container, uiOptions)
}
window.addEventListener('DOMContentLoaded', () => {
  if (navigator.userAgent.includes('miniProgram') || navigator.userAgent.includes('MicroMessenger')) {
    new Promise((resolve, reject) => {
      document.addEventListener('WeixinJSBridgeReady', resolve)
    }).then(bootstrap)
  } else {
    bootstrap()
  }
})

Destory

launcher.destory([errMsg])
0.1.0-beta.0

4 months ago