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();
},