UNPKG

@jp-web/ts-sdk

Version:

视频客服,视频会议Web端及微信小程序端SDK

100 lines (98 loc) 3.14 kB
Component({ properties: { config: { type: Object, value: {}, observer: function (newVal, oldVal) { this._propertyObserver(newVal); } } }, data: { pusherContext: null, pusherId: null, pushConfig: { pushUrl: null, mode: 'RTC', autopush: true, enableCamera: true, autoFocus: true, orientation: 'vertical', beauty: 0, whiteness: 0, aspect: '9:16', minBitrate: 200, maxBitrate: 1000, audioQuality: 'high', waitingImage: './assets/images/wait-background.png', waitingImageHash: '', zoom: false , devicePosition: 'front', backgroundMute: false, remoteMirror: false, localMirror: 'auto', audioReverbType: '0', enableMic: true, enableAgc: false, enableAns: false, audioVolumeType: 'voicecall', videoWidth: 360, videoHeight: 640, debug: false, hidden: false } }, lifetimes: { created() { this.data.pusherId = Date.now().toString(10); }, attached: function () { this.setData({ pusherId: this.data.pusherId, }) this.data.pusherContext = wx.createLivePusherContext(); }, error(err) { console.log(err); } }, methods: { start(options) { this.data.pusherContext.start(options); }, stop(options) { this.data.pusherContext.stop(options); }, pause(options) { this.data.pusherContext.pause(options); }, resume(options) { this.data.pusherContext.resume(options); }, switchCamera(options) { this.data.pusherContext.switchCamera(options); }, snapshot(quality) { return this.data.pusherContext.snapshot(quality); }, playBGM(url, options) { this.data.pusherContext.playBGM({url, ...options}); }, stopBGM(options) { this.data.pusherContext.stopBGM(options); }, pauseBGM(options) { this.data.pusherContext.pauseBGM(options); }, resumeBGM(options) { this.data.pusherContext.resumeBGM(options); }, setBGMVolume(volume, options) { this.data.pusherContext.setBGMVolume({volume, ...options}); }, setMICVolume(volume, options) { this.data.pusherContext.setMICVolume({volume, ...options}); }, startPreview(options) { this.data.pusherContext.startPreview(options); }, stopPreview(options) { this.data.pusherContext.stopPreview(options); }, init(config) { Object.assign(this.data.pushConfig, config); this.setData({ pushConfig: this.data.pushConfig }); console.log(this.data.pushConfig); }, onStateChange(event) {}, onNetStateChange(event) {}, onError(event) {}, onBGMStart(event) {}, onBGMProcess(event) {}, onBGMComplete(event) {}, _propertyObserver(data) { return new Promise((resolve, reject) => { if (!data) { reject(`parameter is null.`); return; } Object.assign(this.data.pushConfig, data.options); this.setData({pushConfig: this.data.pushConfig}, () => resolve()); }); } } })