uni-app 安卓华为直播流控件预览快照2次后闪退
uni-app 安卓华为直播流控件预览快照2次后闪退
| 产品分类 | HBuilderX版本号 | 手机系统 | 手机系统版本号 | 手机厂商 | 手机机型 | 打包方式 |
|---|---|---|---|---|---|---|
| HTML5+ | 3.2.3 | Android | Android 10 | 华为 | nova5i Mate10 | 云端 |
示例代码:
```vue
<template>
<div class="real_time_extract_img">
<x-header :left-options="{backText: '', preventGoBack: true}" [@on-click-back](/user/on-click-back)="onBack">测试</x-header>
<div class="player" id="playerRef"></div>
<button [@click](/user/click)="snapshot">快照</button>
</div>
</template>
<script>
import { XHeader } from 'vux';
export default {
components: {XHeader},
data() {
return {
pusher: null
};
},
mounted() {
this.init();
},
methods: {
init() {
if (!window.plus) return;
document.addEventListener('plusready', this.initPusher(), false);
},
initPusher() {
this.pusher = new window.plus.video.LivePusher('playerRef', {
mode: 'HD',
position: 'static',
top: '47px',
with: '100%',
height: '300px',
bottom: '46px',
muted: true
});
window.plus.webview.currentWebview().append(this.pusher);
this.preview();
// 监听状态变化事件
this.pusher.addEventListener('statechange', function(e) {
console.log('statechange: ' + JSON.stringify(e));
}, false);
// 监听网络状态变化事件
this.pusher.addEventListener('netstatus', function(e) {
console.log('netstatus: ' + JSON.stringify(e));
}, false);
// 监听错误事件
this.pusher.addEventListener('error', function(e) {
console.log('error: ' + JSON.stringify(e));
}, false);
},
preview() {
this.pusher && this.pusher.preview();
},
snapshot() { // 快照
this.pusher && this.pusher.snapshot((e) => {
window.plus.nativeUI.alert('snapshot success: ' + JSON.stringify(e));
}, (e) => {
window.plus.nativeUI.alert('snapshot error: ' + JSON.stringify(e));
});
},
close() {
this.pusher && this.pusher.close();
},
onBack() {
this.$router.back();
this.close();
}
}
};
</script>
<style lang="scss" scoped>
.real_time_extract_img{
box-sizing: border-box;
width: 100vw;
height: 100vh;
overflow: hidden;
padding-top: 47px;
.player{
height: 300px;
}
}
</style>
操作步骤:
- 创建了一个直播流控件,然后预览,点击按钮获取快照,第一次成功了,然后点击第二次获取快照,然后应用就闪退了。
预期结果:
- 每一次点击获取快照都能成功获取。
实际结果:
- 第二次获取快照,应用闪退。
bug描述:
snapshot() { // 快照
this.pusher && this.pusher.snapshot((e) => {
window.plus.nativeUI.alert('snapshot success: ' + JSON.stringify(e));
}, (e) => {
window.plus.nativeUI.alert('snapshot error: ' + JSON.stringify(e));
});
},
安卓调用第一次成功后,第二次应用直接闪退
更多关于uni-app 安卓华为直播流控件预览快照2次后闪退的实战教程也可以访问 https://www.itying.com/category-93-b0.html
12 回复
根据新发的ask地址:https://ask.dcloud.net.cn/question/147593
提供的示例,我复现了闪退的问题,并做了相关处理。
其他问题我无法复现,更具体的回复查看新的ask
更多关于uni-app 安卓华为直播流控件预览快照2次后闪退的实战教程也可以访问 https://www.itying.com/category-93-b0.html
解决了吗?我现在也出现这个问题
我还发现一个问题就是快照拍出来的图片方向不对
我的解决方法是createLivePusher重置
我现在是预览图片返回时会闪退,而且快照的清晰度不行
一年了,问题还有,,,,,,
帮忙提供一下可以复现问题的示例。 我现在试试
回复 DCloud_Android_DQQ: https://ask.dcloud.net.cn/question/147593,这是我昨天发的问题,里面有测试项目,可以复现这个问题。机器使用的是:红米note7(Android 10)和商米q宝(Android 7.1.2)
回复 phoeniix: 我试试
回复 DCloud_Android_DQQ: 这个问题解决没有,vue页面会闪退


