@volcengine/vecasterplayer
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

@volcengine/vecasterplayer

云导播 RTC 播放器

使用流程

业务方接入 服务端NodeSDK 计算 Token, 传入给 WebSDK

鉴权

业务方在node层 使用 github/volcengine/volc-sdk-nodejs 获得 UserToken ,将 UserToken 传入给SDK初始化以及更新Token更新

web 引入

import {
    CasterPlayerRoom, 
    CasterPlayerContentEnum,
    CasterEvent,
} from "@volcengine/vecasterplayer"

// 创建 room 实例
const room = new CasterPlayerRoom({
  UserToken: UserToken,
  CasterID: 1,
})

// Token 更新
room.on(CasterEvent.onUserTokenExpired, async ()=>{
    const NewUserToken = await fetchUserToken()
    room.refreshToken(NewUserToken)
})

// 进云导播房间(必须要进入房间才能创建播放器播放)
room.enterRoom()
// 退出云导播房间(销毁各种副作用)
room.leaveRoom()


// 创建播放器 -> 建立DOM
room.createPlayer(CasterPlayerContentEnum.PVW, divDOM)
// 返回player原生DOM

// 销毁播放器
room.destroyPlayer(CasterPlayerContentEnum.PVW)

// 取消禁音
room.unmuteStreamAudio(CasterPlayerContentEnum.PVW)
// 禁音
room.muteStreamAudio(CasterPlayerContentEnum.PVW)

枚举

enum CasterPlayerContentEnum {
  PVW, PGM, RES_1, RES_2, RES_3, RES_4, RES_5, RES_6
}

enum CasterEvent {
  onUserTokenExpired 
}

类型

type UserToken =  {
    AccessKeyId: string;
    SecretAccessKey: string;
    CurrentTime: string;
    ExpiredTime: string;
    SessionToken: string;
}

type CasterID = number

Package Sidebar

Install

npm i @volcengine/vecasterplayer

Weekly Downloads

13

Version

0.0.2

License

BSD-3-Clause

Unpacked Size

1.55 MB

Total Files

21

Last publish

Collaborators

  • msq17
  • caocun
  • garyyangbyte
  • lvpiao
  • chenping.123
  • bytedance_liutaofe
  • ash.yu
  • zhenran.sz
  • vcloud_fe
  • zhuhongshuyu
  • wangyx.byte
  • shushushu
  • zhoulei
  • shanggw
  • liangshuang.fiona
  • zhengwenyue
  • wallaceyuan
  • cmaxd
  • liuzhao.90
  • liucheng.bigorange
  • zhouyk
  • oanakiaja
  • chenyongjin
  • lixiangfeiorg
  • awesome-starling
  • zhang6464
  • volcanoengine
  • bytednpm