html52.com
我爱小程序-开发者交流社区

LivePusherContext.startPreview() 不能提前打开摄像头预览吗?

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

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

网友回复

娇华:

你好,这个就是在推流前可以打开预览,麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(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();

},


评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付