提交 b691c1e4 编写于 作者: fxy060608's avatar fxy060608

update recorder

上级 1b78ba6c
import { import {
onMethod, onMethod,
invokeMethod invokeMethod
} from '../../platform' } from '../../platform'
const callbacks = { const callbacks = {
pause: [], pause: [],
resume: [], resume: [],
start: [], start: [],
stop: [] stop: []
} }
class RecorderManager { class RecorderManager {
constructor () { constructor () {
callbacks = onMethod('onRecorderStateChange', res => {
onMethod('onRecorderStateChange', res => { const state = res.state
const state = res.state delete res.state
delete res.state delete res.errMsg
delete res.errMsg callbacks[state].forEach(callback => {
callbacks[state].forEach(callback => { if (typeof callback === 'function') {
if (typeof callback === 'function') { callback(res)
callback(res) }
} })
}) })
}) }
} onError (callback) {
onError (callback) { callbacks.error.push(callback)
callbacks.error.push(callback) }
} onFrameRecorded (callback) {
onFrameRecorded (callback) {
}
} onInterruptionBegin (callback) {
onInterruptionBegin (callback) {
}
} onInterruptionEnd (callback) {
onInterruptionEnd (callback) {
}
} onPause (callback) {
onPause (callback) { callbacks.pause.push(callback)
callbacks.pause.push(callback) }
} onResume (callback) {
onResume (callback) { callbacks.resume.push(callback)
callbacks.resume.push(callback) }
} onStart (callback) {
onStart (callback) { callbacks.start.push(callback)
callbacks.start.push(callback) }
} onStop (callback) {
onStop (callback) { callbacks.stop.push(callback)
callbacks.stop.push(callback) }
} pause () {
pause () { invokeMethod('operateRecorder', {
invokeMethod('operateRecorder', { operationType: 'pause'
operationType: 'pause' })
}) }
} resume () {
resume () { invokeMethod('operateRecorder', {
invokeMethod('operateRecorder', { operationType: 'resume'
operationType: 'resume' })
}) }
} start (options) {
start (options) { invokeMethod('operateRecorder', Object.assign({}, options, {
invokeMethod('operateRecorder', Object.assign({}, options, { operationType: 'start'
operationType: 'start' }))
})) }
} stop () {
stop () { invokeMethod('operateRecorder', {
invokeMethod('operateRecorder', { operationType: 'stop'
operationType: 'stop' })
}) }
} }
}
let recorderManager
let recorderManager
export function getRecorderManager () {
export function getRecorderManager () { return recorderManager || (recorderManager = new RecorderManager())
return recorderManager || (recorderManager = new RecorderManager())
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册