uniapp 对接声网拉流

发布于 2025-08-16 18:23:20

 地址:https://doc.shengwang.cn/doc/rtc/javascript/get-started/enable-service

第一步:AgoraRTC.enableLogUpload()

this.client = AgoraRTC.createClient({

mode: AGORA_CLIENT_MODE.LIVE,

codec: AGORA_CODEC.VP8

})

// 设置观众角色并启用极速直播(低延时)

const clientRoleOptions = {

level: this.audienceLatency // 延时等级设为1,实现低延时

}

this.client.setClientRole(AGORA_CLIENT_ROLE.AUDIENCE, clientRoleOptions)

console.log(`创建直播模式客户端(观众角色,延时等级${this.audienceLatency})`)

// 设置事件监听器

this.setupEventListeners()

this.statusText = 'SDK初始化成功'

console.log('声网SDK初始化成功')

console.log('事件监听器已设置')

// 检查事件监听器是否正确绑定

this.checkEventListeners()

第二步await this.client.join(this.appId, this.channelName, this.token, this.uid)

第三步<!-- 声网直播 -->

<view class="player-container">

<!-- 直播模式:远程视频 -->

<view class="video-container">

<div id="remote-video" class="remote-video"></div>

<view v-if="!isPlaying" class="placeholder">

<text>等待播放...</text>

</view>

</view>

</view>播放器播放

0 条评论

发布
问题