vue项目中的nvue页面
<template>
<view>
<live-pusher id='livePusher' ref="livePusher" class="livePusher" url=""
mode="SD" :muted="true" :enable-camera="true" :auto-focus="true" :beauty="1" whiteness="2"
aspect="9:16" @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() {
console.log('--');
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>
6 个回复
最佳回复
DCloud_Android_YJC
HBuilderX 3.6.16-alpha 已修复
DCloud_Android_ST
请提供具体示例demo
信赖的阿涛 (作者)
报错是渲染错误事件,官方demo在nvue使用。
2022-12-30 09:01
DCloud_Android_ST
回复 信赖的阿涛: 提供demo是方便我们快速定位问题 很多细节决定bug的问题复现 所以还是推荐提供简单示例demo
2022-12-30 10:56
信赖的阿涛 (作者)
回复 DCloud_Android_ST: 发了
2023-01-03 08:54
DCloud_Android_ST
回复 信赖的阿涛: 你附件上传demo
2023-01-03 14:25
信赖的阿涛 (作者)
回复 DCloud_Android_ST: demo发了
2023-01-03 14:39
信赖的阿涛 (作者)
vue项目中的nvue页面
<template>
<view>
<live-pusher id='livePusher' ref="livePusher" class="livePusher" url=""
mode="SD" :muted="true" :enable-camera="true" :auto-focus="true" :beauty="1" whiteness="2"
aspect="9:16" @statechange="statechange" @netstatus="netstatus" @error = "error"
<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() {
console.log('--');
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>
信赖的阿涛 (作者)
<template>
<view>
<live-pusher id='livePusher' ref="livePusher" class="livePusher" url=""
mode="SD" :muted="true" :enable-camera="true" :auto-focus="true" :beauty="1" whiteness="2"
aspect="9:16" @statechange="statechange" @netstatus="netstatus" @error = "error"
信赖的阿涛 (作者)
demo
DCloud_Android_YJC
能具体描述一下demo的复现步骤么?使用的HX版本是多少?
2023-01-04 16:16
信赖的阿涛 (作者)
回复 DCloud_Android_YJC: 版本是3.6.14 alpha,复现场景是:首次打开页面,获取权限相机和麦克风,确认后,出现摄像头预览画面,后执行程序逻辑正常,这时候发现,如果退出app(后台删除进度),再次打开页面,摄像头预览界面是黑屏的(现测试华为鸿蒙系统发现此问题,ios可以使用)。可以加我qq,1422253137,有操作视频。
2023-01-05 09:04
信赖的阿涛 (作者)
回复 信赖的阿涛: 此页面为vue项目中使用的nvue页面。
2023-01-05 09:38
m***@163.com
作者您好, 请问你最后解决这个问题了嘛? 我也遇到同样的问题,切换到后台再打开就是黑屏
信赖的阿涛 (作者)
解决了,更新下hbuilderx,然后重新打自定义基座包。
2024-03-18 10:27