From 2da90d07c36900fa7b899940cba32be3335dc879 Mon Sep 17 00:00:00 2001 From: mehaotian <490272692@qq.com> Date: Sat, 1 Jun 2019 19:21:03 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20live-pusher=20=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/api/context/live-pusher.js | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/src/platforms/app-plus-nvue/services/api/context/live-pusher.js b/src/platforms/app-plus-nvue/services/api/context/live-pusher.js index e69de29bb..506fe1d8b 100644 --- a/src/platforms/app-plus-nvue/services/api/context/live-pusher.js +++ b/src/platforms/app-plus-nvue/services/api/context/live-pusher.js @@ -0,0 +1,76 @@ +import { + findRefById, + invokeVmMethod, + invokeVmMethodWithoutArgs +} from '../util' + +class LivePusherContext { + constructor (id, ctx) { + this.id = id + this.ctx = ctx + } + + start (cbs) { + return invokeVmMethodWithoutArgs(this.ctx, 'start', cbs) + } + + stop (cbs) { + return invokeVmMethodWithoutArgs(this.ctx, 'stop', cbs) + } + + pause (cbs) { + return invokeVmMethodWithoutArgs(this.ctx, 'pause', cbs) + } + + resume (cbs) { + return invokeVmMethodWithoutArgs(this.ctx, 'resume', cbs) + } + + switchCamera (cbs) { + return invokeVmMethodWithoutArgs(this.ctx, 'switchCamera', cbs) + } + + snapshot (cbs) { + return invokeVmMethodWithoutArgs(this.ctx, 'snapshot', cbs) + } + + toggleTorch (cbs) { + return invokeVmMethodWithoutArgs(this.ctx, 'toggleTorch', cbs) + } + + playBGM (args) { + return invokeVmMethod(this.ctx, 'playBGM', args) + } + + stopBGM (cbs) { + return invokeVmMethodWithoutArgs(this.ctx, 'stopBGM', cbs) + } + + pauseBGM (cbs) { + return invokeVmMethodWithoutArgs(this.ctx, 'pauseBGM', cbs) + } + + resumeBGM (cbs) { + return invokeVmMethodWithoutArgs(this.ctx, 'resumeBGM', cbs) + } + + setBGMVolume (cbs) { + return invokeVmMethod(this.ctx, 'setBGMVolume', cbs) + } + + startPreview (cbs) { + return invokeVmMethodWithoutArgs(this.ctx, 'startPreview', cbs) + } + + stopPreview (args) { + return invokeVmMethodWithoutArgs(this.ctx, 'stopPreview', args) + } +} + +export function createLivePusherContext (id, vm) { + const ref = findRefById(id, vm) + if (!ref) { + global.nativeLog('Can not find `' + id + '`', '__WARN') + } + return new LivePusherContext(id, vm.$refs[ref]) +} -- GitLab