DaYao
DaYao
  • 发布:2025-08-06 15:31
  • 更新:2025-08-06 15:31
  • 阅读:66

【报Bug】【已解决】live-pusher推流组件没有声音

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 26100.3775

HBuilderX类型: 正式

HBuilderX版本号: 4.66

手机系统: Android

手机系统版本号: Android 15

手机厂商: 小米

手机机型: 小米15

页面类型: nvue

vue版本: vue3

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
<template> <view> <live-pusher id='livePusher' ref="livePusher" class="livePusher" url="rtmp://gwm-000-cn-0604.bcloud365.net:9016/talk_5a9a0b11b208efd90/M3w1YTlhMGIxMWIyMDhlZmQ5fGZhM2NiMzljOThkZjlmYjU3MDA5OGQzMzdlNWUyZTQxZDIwZm8FmZDJkZmMxZmI5Y2UyY2FhNmY1NDVlYWQ3YmV8cnRtcHwxNzU0NDYyNDk4fDE3NTYyNTI5NjA%3D.b8b022dfddc97da47d06a0b0a33b5b5d" enable-camera="false" @statechange="statechange" @netstatus="netstatus" @error="error"></live-pusher> <button class="btn" @click="start">开始推流</button>
<button class="btn" @click="pause">暂停推流</button>
<button class="btn" @click="resume">resume</button>
<button class="btn" @click="stop">停止推流</button>
<button class="btn" @click="snapshot">快照</button>
<button class="btn" @click="startPreview">开启摄像头预览</button>
<button class="btn" @click="stopPreview">关闭摄像头预览</button>
<button class="btn" @click="switchCamera">切换摄像头</button>
</view>
</template>

<script>
export default {
data() {
return {}
},
onReady() {
// 注意:需要在onReady中 或 onLoad 延时
this.context = uni.createLivePusherContext("livePusher", this);
},
methods: {
statechange(e) {
console.log("statechange:" + JSON.stringify(e));
},
netstatus(e) {
console.log("netstatus:" + JSON.stringify(e));
},
error(e) {
console.log("error:" + JSON.stringify(e));
},
start: function() {
this.context.start({
success: (a) => {
console.log("livePusher.start:" + JSON.stringify(a));
}
});
},
close: function() {
this.context.close({
success: (a) => {
console.log("livePusher.close:" + JSON.stringify(a));
}
});
},
snapshot: function() {
this.context.snapshot({
success: (e) => {
console.log(JSON.stringify(e));
}
});
},
resume: function() {
this.context.resume({
success: (a) => {
console.log("livePusher.resume:" + JSON.stringify(a));
}
});
},
pause: function() {
this.context.pause({
success: (a) => {
console.log("livePusher.pause:" + JSON.stringify(a));
}
});
},
stop: function() {
this.context.stop({
success: (a) => {
console.log(JSON.stringify(a));
}
});
},
switchCamera: function() {
this.context.switchCamera({
success: (a) => {
console.log("livePusher.switchCamera:" + JSON.stringify(a));
}
});
},
startPreview: function() {
this.context.startPreview({
success: (a) => {
console.log("livePusher.startPreview:" + JSON.stringify(a));
}
});
},
stopPreview: function() {
this.context.stopPreview({
success: (a) => {
console.log("livePusher.stopPreview:" + JSON.stringify(a));
}
});
}
}
}
</script>

<style>
.livePusher {
width: 0;
height: 0;
}
</style>

操作步骤:

配置项:muted默认false(不静音),enable-mic默认true(开启麦克风)

由于需求不需要直播画面所以将enable-camera设置为false(关闭摄像头)

预期结果:

可以收到推送的声音

实际结果:

没有收到推送的声音

bug描述:

问题:
live-pusher组件使用官方示例代码测试推送,推流连接、推送状态正常,但是接收方没有声音。

控制台日志:

测试结果:
APP测试无声音。小程序测试有声音,小程序使用的APPID有live-pusher组件权限

2025-08-06 15:31 负责人:无 分享
已邀请:

要回复问题请先登录注册