All checks were successful
Plugin Library CI / publish (00.BuildOriginality) (push) Successful in 13s
Plugin Library CI / publish (00.StaryEvo) (push) Successful in 17s
Plugin Library CI / publish (00.StaryEvoTools) (push) Successful in 35s
Plugin Library CI / publish (01.HybridCLR) (push) Successful in 15s
Plugin Library CI / publish (02.InformationSave) (push) Successful in 3s
Plugin Library CI / publish (03.YooAsset) (push) Successful in 33s
Plugin Library CI / publish (04.AudioCore) (push) Successful in 3s
Plugin Library CI / publish (05.TableTextConversion) (push) Successful in 5s
Plugin Library CI / publish (06.UIFarme) (push) Successful in 15s
Plugin Library CI / publish (07.RKTools) (push) Successful in 2s
Plugin Library CI / publish (08.UniTask) (push) Successful in 3s
Plugin Library CI / publish (09.CodeChecker) (push) Successful in 16s
Plugin Library CI / publish (10.StoryEditor) (push) Successful in 3s
Plugin Library CI / publish (10.XNode) (push) Successful in 3s
Plugin Library CI / publish (11.PointCloudTools) (push) Successful in 2s
Plugin Library CI / publish (12.WeixinMinigame) (push) Successful in 2m32s
157 lines
4.4 KiB
JavaScript
157 lines
4.4 KiB
JavaScript
import moduleHelper from './module-helper';
|
|
import { formatJsonStr, cacheArrayBuffer, getListObject, uid } from './utils';
|
|
const recorderManagerList = {};
|
|
const getObject = getListObject(recorderManagerList, 'video');
|
|
export default {
|
|
WX_GetRecorderManager() {
|
|
const id = uid();
|
|
recorderManagerList[id] = wx.getRecorderManager();
|
|
return id;
|
|
},
|
|
WX_OnRecorderError(id) {
|
|
const obj = getObject(id);
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
const callback = (res) => {
|
|
const resStr = JSON.stringify({
|
|
callbackId: id,
|
|
res: JSON.stringify(res),
|
|
});
|
|
moduleHelper.send('_OnRecorderErrorCallback', resStr);
|
|
};
|
|
obj.onError(callback);
|
|
},
|
|
WX_OnRecorderFrameRecorded(id) {
|
|
const obj = getObject(id);
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
const callback = (res) => {
|
|
cacheArrayBuffer(id, res.frameBuffer);
|
|
const resStr = JSON.stringify({
|
|
callbackId: id,
|
|
res: JSON.stringify({
|
|
frameBufferLength: res.frameBuffer.byteLength,
|
|
isLastFrame: res.isLastFrame,
|
|
}),
|
|
});
|
|
moduleHelper.send('_OnRecorderFrameRecordedCallback', resStr);
|
|
};
|
|
obj.onFrameRecorded(callback);
|
|
},
|
|
WX_OnRecorderInterruptionBegin(id) {
|
|
const obj = getObject(id);
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
const callback = (res) => {
|
|
const resStr = JSON.stringify({
|
|
callbackId: id,
|
|
res: JSON.stringify(res),
|
|
});
|
|
moduleHelper.send('_OnRecorderInterruptionBeginCallback', resStr);
|
|
};
|
|
obj.onInterruptionBegin(callback);
|
|
},
|
|
WX_OnRecorderInterruptionEnd(id) {
|
|
const obj = getObject(id);
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
const callback = (res) => {
|
|
const resStr = JSON.stringify({
|
|
callbackId: id,
|
|
res: JSON.stringify(res),
|
|
});
|
|
moduleHelper.send('_OnRecorderInterruptionEndCallback', resStr);
|
|
};
|
|
obj.onInterruptionEnd(callback);
|
|
},
|
|
WX_OnRecorderPause(id) {
|
|
const obj = getObject(id);
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
const callback = (res) => {
|
|
const resStr = JSON.stringify({
|
|
callbackId: id,
|
|
res: JSON.stringify(res),
|
|
});
|
|
moduleHelper.send('_OnRecorderPauseCallback', resStr);
|
|
};
|
|
obj.onPause(callback);
|
|
},
|
|
WX_OnRecorderResume(id) {
|
|
const obj = getObject(id);
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
const callback = (res) => {
|
|
const resStr = JSON.stringify({
|
|
callbackId: id,
|
|
res: JSON.stringify(res),
|
|
});
|
|
moduleHelper.send('_OnRecorderResumeCallback', resStr);
|
|
};
|
|
obj.onResume(callback);
|
|
},
|
|
WX_OnRecorderStart(id) {
|
|
const obj = getObject(id);
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
const callback = (res) => {
|
|
const resStr = JSON.stringify({
|
|
callbackId: id,
|
|
res: JSON.stringify(res),
|
|
});
|
|
moduleHelper.send('_OnRecorderStartCallback', resStr);
|
|
};
|
|
obj.onStart(callback);
|
|
},
|
|
WX_OnRecorderStop(id) {
|
|
const obj = getObject(id);
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
const callback = (res) => {
|
|
const resStr = JSON.stringify({
|
|
callbackId: id,
|
|
res: JSON.stringify(res),
|
|
});
|
|
moduleHelper.send('_OnRecorderStopCallback', resStr);
|
|
};
|
|
obj.onStop(callback);
|
|
},
|
|
WX_RecorderPause(id) {
|
|
const obj = getObject(id);
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
obj.pause();
|
|
},
|
|
WX_RecorderResume(id) {
|
|
const obj = getObject(id);
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
obj.resume();
|
|
},
|
|
WX_RecorderStart(id, option) {
|
|
const obj = getObject(id);
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
const conf = formatJsonStr(option);
|
|
obj.start(conf);
|
|
},
|
|
WX_RecorderStop(id) {
|
|
const obj = getObject(id);
|
|
if (!obj) {
|
|
return;
|
|
}
|
|
obj.stop();
|
|
},
|
|
};
|