Skip to content

Commit

Permalink
feat: live-pusher 代码实现
Browse files Browse the repository at this point in the history
  • Loading branch information
mehaotian committed Jun 1, 2019
1 parent 94d7a1c commit 2da90d0
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions src/platforms/app-plus-nvue/services/api/context/live-pusher.js
Original file line number Diff line number Diff line change
@@ -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])
}

0 comments on commit 2da90d0

Please sign in to comment.