LivePusherContext.startPreview() 不能提前打开摄像头预览吗?
发布于 6 年前 作者 tsong 10251 次浏览 来自 官方Issues

LivePusherContext.startPreview 这个方法是干什么用的,为什么我的live-pusher组件中使用这个方法无法提前打开摄像头预览呢?必须要等到推流成功以后,才能开启摄像头呢?

期望:进入页面后,就可以开启摄像头预览。

2 回复

你好,这个就是在推流前可以打开预览,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

live-pusher是写在组件里面的,虽然我把startPreview()方法写在ready里面,但是每次都得等到推流成功后才能打开摄像头画面。startPreview是异步的吗?

<live-pusher wx:if="{{pushURL}}" id=“rtcpusher” autopush mode=“RTC” url="{{pushURL}}" aspect="{{aspect}}" min-bitrate="{{minBitrate}}" max-bitrate="{{maxBitrate}}" audio-quality=“low” beauty="{{beauty}}" whiteness="{{whiteness}}" muted="{{muted}}" waiting-image="{{waitingImg}}" background-mute="{{false}}" debug="{{debug}}" bindstatechange=“onPush” binderror=“onError” enable-camera="{{enableCamera}}"></live-pusher>

ready: function () {

    self = this;

     if (!this.data.pusherContext) {

        this.data.pusherContext = wx.createLivePusherContext(‘rtcpusher’);

    }     this.data.pusherContext.startPreview();

},

回到顶部