智能照明系统APP-本地串口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
LightingSystemApp-serial/.svn/pristine/40/40278b860359ac28e68f2d72946...

88 lines
1.3 KiB

3 years ago
import {
onMethod,
invokeMethod
} from '../../platform'
const callbacks = {
pause: null,
resume: null,
start: null,
stop: null,
error: null
}
class RecorderManager {
constructor () {
onMethod('onRecorderStateChange', res => {
const state = res.state
delete res.state
delete res.errMsg
if (typeof callbacks[state] === 'function') {
callbacks[state](res)
}
})
}
onError (callback) {
callbacks.error = callback
}
onFrameRecorded (callback) {
}
onInterruptionBegin (callback) {
}
onInterruptionEnd (callback) {
}
onPause (callback) {
callbacks.pause = callback
}
onResume (callback) {
callbacks.resume = callback
}
onStart (callback) {
callbacks.start = callback
}
onStop (callback) {
callbacks.stop = callback
}
pause () {
invokeMethod('operateRecorder', {
operationType: 'pause'
})
}
resume () {
invokeMethod('operateRecorder', {
operationType: 'resume'
})
}
start (options) {
invokeMethod('operateRecorder', Object.assign({}, options, {
operationType: 'start'
}))
}
stop () {
invokeMethod('operateRecorder', {
operationType: 'stop'
})
}
}
let recorderManager
export function getRecorderManager () {
return recorderManager || (recorderManager = new RecorderManager())
}