2***@qq.com
2***@qq.com
  • 发布:2021-12-23 14:47
  • 更新:2021-12-23 16:56
  • 阅读:334

live-puser.微信开发工具一直闪退

分类:uni-app

最近在做小程序直播功能,对接腾讯云直播。
然而单页面中只写一个live-pusher、只要打开页面、微信开发工具就闪退。
这个我就懵了。
排错都不知道怎么下手,哪位大大有遇到过类似情况的、麻烦告知。

代码是官方的示例代码
在此谢谢了

<template>  
    <view class="uni-container">  
        <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 {  
                        context: null  
                    }  
                },  
                onReady() {  
                    let self = this  
                    // 注意:需要在onReady中 或 onLoad 延时  
                    setTimeout(function(){  
                        self.context = uni.createLivePusherContext("livePusher", self);  
                    },1500)  
                },  
                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>  
</style>
2021-12-23 14:47 负责人:无 分享
已邀请:
2***@qq.com

2***@qq.com (作者)

问题已找到!
live-pusher 不能在微信开发工具直接使用!!!

该问题目前已经被锁定, 无法添加新回复