更新记录
1.0.0(2025-12-18)
初次提交
平台兼容性
一、部署livekit server 1、安装 Livekit Server curl -sSL https://get.livekit.io | bash 2、启用运行 ./livekit-server --config config.yaml --node-ip 8.8.8.8 –node-ip 8.8.8.8 修改为你的外网IP 配置config.yml port: 7880 log_level: info rtc: tcp_port: 7881 port_range_start: 50000 port_range_end: 60000
keys: yhpbs: 26148d621ef74844918af182d63976b6 turn: enabled: true udp_port: 5161 tls_port: 443 domain: TURN TLS域名 cert_file: TURN TLS域名ssl证书绝对路径 key_file: TURN TLS域名ssl证书密钥绝对路径 3、生成token 请先使用Server API SDK进行用户Token的生成,具体操作方式请查看官方文档
二、前端调用
1、调用插件
const LiveKitModule = uni.requireNativePlugin('LiveKitModule');
2、初始化
LiveKitModule.initialize();
3、加入房间
LiveKitModule.joinRoom(url, token, res => {});
4、获取本地用户
LiveKitModule.getLocalParticipant(res => {});
5、获取所有参与者
LiveKitModule.getParticipants(res => {});
6、设置麦克风开关
LiveKitModule.toggleMic(enabled, () => {
console.log(麦克风已${enabled ? '开启' : '关闭'});
});
7、设置扬声器开关
LiveKitModule.toggleSpeaker(enabled, () => {
console.log(扬声器已${enabled ? '开启' : '关闭'});
});
8、开启关闭摄像头
LiveKitModule.toggleVideo(enabled, (res) => {
if (res && res.success) {
console.log(摄像头已${enabled ? '开启' : '关闭'});
} else {
console.error('摄像头控制失败:', res?.error || '未知错误');
}
});
9、切换摄像头
LiveKitModule.switchCamera((res) => {
if (res && res.success) {
console.log('摄像头切换成功');
resolve(res);
} else {
console.error('摄像头切换失败:', res?.error || '未知错误');
reject(new Error(res?.error || '摄像头切换失败'));
}
});
10、离开房间
LiveKitModule.leaveRoom(() => {});

收藏人数:
购买源码授权版(
试用
赞赏(0)
下载 42
赞赏 0
下载 12397980
赞赏 1829
赞赏
京公网安备:11010802035340号