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 7ef79494679079817e692f56eae70c4f8d0c658a..636eefe2fee3a664edb741e2acff57be540240a4 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 71d6b1391f68367d2d6c946cca518e420a7d9d9e..b0bdabb22e1985d6ba93234d04a7d1ded0670afb 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) } } }