//拍照
this.livePusher.snapshot({
success: (e) => {
console.log(e);
},
complete: (err) => {
console.log(err)
}
})
- 发布:2022-08-02 12:29
- 更新:2023-04-18 15:19
- 阅读:1037
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: W11
HBuilderX类型: 正式
HBuilderX版本号: 3.5.3
手机系统: Android
手机系统版本号: Android 7.0
手机机型: 设备
页面类型: vue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
//拍照
this.livePusher.snapshot({
success: (e) => {
console.log(e);
},
complete: (err) => {
console.log(err)
}
})
//拍照
this.livePusher.snapshot({
success: (e) => {
console.log(e);
},
complete: (err) => {
console.log(err)
}
})
预期结果:
//拍照
this.livePusher.snapshot({
success: (e) => {
console.log(e);
},
complete: (err) => {
console.log(err)
}
})
//拍照
this.livePusher.snapshot({
success: (e) => {
console.log(e);
},
complete: (err) => {
console.log(err)
}
})
实际结果:
//拍照
this.livePusher.snapshot({
success: (e) => {
console.log(e);
},
complete: (err) => {
console.log(err)
}
})
//拍照
this.livePusher.snapshot({
success: (e) => {
console.log(e);
},
complete: (err) => {
console.log(err)
}
})
bug描述:
livePusher组件,snapshot拍照方法不走回调,并且调用多次APP就闪退
a***@newxsy.com (作者)
<template>
<view class="camera">
<view class="live-camera" @click="shutter">
<live-pusher
id="livePusher"
ref="livePusher"
class="livePusher"
mode="FHD"
beauty="0"
whiteness="0"
:aspect="aspect"
min-bitrate="200"
max-bitrate="1000"
audio-quality="16KHz"
device-position="back"
:auto-focus="true"
:muted="true"
:enable-camera="true"
:enable-mic="false"
:zoom="false"
@statechange="stateChange"
></live-pusher>
</view>
</view>
</template>
<script>
export default {
data() {
return {
cameraState: false,
openCarmeInterval: null,
livePusher: null,
aspect: '3:4'
}
},
onReady() {
this.init()
},
methods: {
init() {
this.livePusher = uni.createLivePusherContext('livePusher', this);
this.livePusher.startPreview({
success: a => {
console.log(a)
},
fail: err => {
console.log(err)
}
});
this.openCarmeInterval = setInterval(_ => {
if (!this.cameraState) {
this.livePusher.startPreview({
success: a => {
console.log(a)
},
fail: err => {
console.log(err)
}
});
}
}, 2000);
},
shutter() {
this.$tips.show('shutter')
this.livePusher.snapshot(e => {
console.log(e);
})
},
stateChange(e) {
if (e.detail.code == 1007) {
this.cameraState = true;
} else if (e.detail.code == -1301) {
this.cameraState = false;
}
},
}
}
</script>
<style lang="scss" scoped>
.live-camera {
width: 100vw;
height: 900rpx;
padding-top: 0rpx;
display: flex;
justify-content: center;
align-items: center;
.livePusher {
padding: 0;
width: 100vw;
height: 900rpx;
top: 0;
}
}
</style>
···
a***@newxsy.com (作者)
发了,麻烦看下
2022-08-02 13:13
1***@qq.com
回复 a***@newxsy.com: 请问解决了嘛 我也出现了这个问题
2023-03-15 16:27
9***@qq.com
回复 1***@qq.com: 你的现在解决了吗 我也是遇到这个问题了 你是怎么解决的
2023-04-10 14:50
1***@qq.com
回复 9***@qq.com: 请问解决了吗
2023-04-18 14:50
9***@qq.com
回复 1***@qq.com: 请问解决了吗
2023-10-19 17:57