@slan-health/taro-vueuse
Version:
taro vue版本hooks
27 lines (26 loc) • 908 B
JavaScript
import { getRecorderManager } from "@tarojs/taro";
import useDeviceAuth from "../useDeviceAuth/index.js";
function useRecorderManager(option) {
const recorderManager = getRecorderManager();
const [requestDeviceAuth] = useDeviceAuth();
if (!option) {
throw new Error("please set option property");
}
const { onStart, onPause, onStop, onError, recorderStatus } = option;
const startRecorder = (options) => {
requestDeviceAuth({
scope: "scope.record"
}).then(() => {
recorderStatus() && recorderManager.start(options);
});
};
recorderManager.onStart(onStart);
recorderManager.onPause(onPause);
recorderManager.onStop(onStop);
recorderManager.onError(onError);
return [recorderManager, { startRecorder, stopRecorder: recorderManager.stop, pauseRecorder: recorderManager.pause }];
}
export {
useRecorderManager as default
};
//# sourceMappingURL=index.js.map