@volcengine/vecasterplayer
v0.0.2
Published
火山引擎-云导播预览WebSDK
Downloads
4
Readme
@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