From b863a8e1d93449210a06a3a1706345a0ac8136ad Mon Sep 17 00:00:00 2001 From: handongxun Date: Tue, 1 Mar 2022 17:21:13 +0800 Subject: [PATCH] =?UTF-8?q?feat(app-vue):=20=20=E6=94=AF=E6=8C=81=20live-p?= =?UTF-8?q?usher=20=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/api/context/live-pusher.js | 17 +++++-- .../view/components/live-pusher/index.vue | 51 ++++++++++++------- 2 files changed, 45 insertions(+), 23 deletions(-) diff --git a/src/platforms/app-plus/service/api/context/live-pusher.js b/src/platforms/app-plus/service/api/context/live-pusher.js index 7ef7949467..636eefe2fe 100644 --- a/src/platforms/app-plus/service/api/context/live-pusher.js +++ b/src/platforms/app-plus/service/api/context/live-pusher.js @@ -4,7 +4,7 @@ import { function operateLivePusher (livePusherId, pageVm, type, data) { const pageId = pageVm.$page.id - UniServiceJSBridge.publishHandler(pageId + '-live-pusher-' + livePusherId, { + UniServiceJSBridge.publishHandler(pageId + '-livepusher-' + livePusherId, { livePusherId, type, data @@ -18,13 +18,21 @@ UniServiceJSBridge.subscribe('onLivePusherMethodCallback', ({ callback.invoke(callbackId, data) }) -const methods = ['preview', +const methods = [ 'start', 'stop', 'pause', 'resume', 'switchCamera', - 'snapshot'] + 'startPreview', + 'stopPreview', + 'snapshot' +] + +const methodMapping = { + startPreview: 'preview', + stopPreview: 'stop' +} export class LivePusherContext { constructor (id, pageVm) { @@ -43,7 +51,8 @@ export class LivePusherContext { methods.forEach(function (method) { LivePusherContext.prototype[method] = callback.warp(function (options, callbackId) { options.callbackId = callbackId - operateLivePusher(this.id, this.pageVm, method, options) + const methodName = methodMapping[method] ? methodMapping[method] : method + operateLivePusher(this.id, this.pageVm, methodName, options) }) }) diff --git a/src/platforms/app-plus/view/components/live-pusher/index.vue b/src/platforms/app-plus/view/components/live-pusher/index.vue index 71d6b1391f..b0bdabb22e 100644 --- a/src/platforms/app-plus/view/components/live-pusher/index.vue +++ b/src/platforms/app-plus/view/components/live-pusher/index.vue @@ -15,16 +15,6 @@ import { } from 'uni-mixins' import native from '../../mixins/native' -const methods = [ - 'preview', - 'start', - 'stop', - 'pause', - 'resume', - 'switchCamera', - 'snapshot' -] - const events = [ 'statechange', 'netstatus', @@ -34,17 +24,19 @@ const events = [ const attrs = [ 'url', 'mode', - 'muted' + 'muted', + 'enableCamera', + 'autoFocus', + 'beauty', + 'whiteness', + 'aspect', + 'minBitrate' ] export default { name: 'LivePusher', mixins: [subscriber, native], props: { - id: { - type: String, - default: '' - }, url: { type: String, default: '' @@ -56,6 +48,30 @@ export default { muted: { type: [Boolean, String], default: false + }, + enableCamera: { + type: [Boolean, String], + default: true + }, + autoFocus: { + type: [Boolean, String], + default: true + }, + beauty: { + type: [Number, String], + default: 0 + }, + whiteness: { + type: [Number, String], + default: 0 + }, + aspect: { + type: [String], + default: '3:2' + }, + minBitrate: { + type: [Number], + default: 200 } }, computed: { @@ -105,10 +121,7 @@ export default { type, data = {} }) { - console.log('_handleSubscribe type::' + type) - if (methods.includes(type)) { - this.livePusher && this.livePusher[type](data) - } + this.livePusher && this.livePusher[type](data) } } } -- GitLab