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 e698820b02ea4daaf523b7efa56ef5d4da02e2b5..7ef79494679079817e692f56eae70c4f8d0c658a 100644 --- a/src/platforms/app-plus/service/api/context/live-pusher.js +++ b/src/platforms/app-plus/service/api/context/live-pusher.js @@ -1,7 +1,52 @@ import { - createLivePusherContext as createLivePusher -} from 'uni-platforms/app-plus-nvue/service/api/context/live-pusher' + callback +} from 'uni-shared' -export function createLivePusherContext (id, vm) { - return createLivePusher(id, vm) +function operateLivePusher (livePusherId, pageVm, type, data) { + const pageId = pageVm.$page.id + UniServiceJSBridge.publishHandler(pageId + '-live-pusher-' + livePusherId, { + livePusherId, + type, + data + }, pageId) +} + +UniServiceJSBridge.subscribe('onLivePusherMethodCallback', ({ + callbackId, + data +}) => { + callback.invoke(callbackId, data) +}) + +const methods = ['preview', + 'start', + 'stop', + 'pause', + 'resume', + 'switchCamera', + 'snapshot'] + +export class LivePusherContext { + constructor (id, pageVm) { + this.id = id + this.pageVm = pageVm + } + + on (name, callback) { + operateLivePusher(this.id, this.pageVm, 'on', { + name, + callback + }) + } +} + +methods.forEach(function (method) { + LivePusherContext.prototype[method] = callback.warp(function (options, callbackId) { + options.callbackId = callbackId + operateLivePusher(this.id, this.pageVm, method, options) + }) +}) + +export function createLivePusherContext (id, context) { + return new LivePusherContext(id, context) } diff --git a/src/platforms/app-plus/view/components/live-pusher/index.vue b/src/platforms/app-plus/view/components/live-pusher/index.vue new file mode 100644 index 0000000000000000000000000000000000000000..71d6b1391f68367d2d6c946cca518e420a7d9d9e --- /dev/null +++ b/src/platforms/app-plus/view/components/live-pusher/index.vue @@ -0,0 +1,149 @@ + + + +