UNPKG

theta-client-react-native

Version:

This library provides a way to control RICOH THETA using.

124 lines (118 loc) 4.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CompositeIntervalCaptureBuilder = exports.CompositeIntervalCapture = void 0; var _capture = require("./capture"); var _NativeThetaClientReactNative = _interopRequireDefault(require("../NativeThetaClientReactNative")); var _notifyController = require("../theta-repository/notify-controller"); function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } const NOTIFY_PROGRESS = 'COMPOSITE-INTERVAL-PROGRESS'; const NOTIFY_STOP_ERROR = 'COMPOSITE-INTERVAL-STOP-ERROR'; const NOTIFY_CAPTURING = 'COMPOSITE-INTERVAL-CAPTURING'; /** * CompositeIntervalCapture class */ class CompositeIntervalCapture { constructor(notify) { this.notify = notify; } /** * start interval composite shooting * @param onProgress the block for interval composite shooting onProgress * @param onStopFailed Called when stopCapture error occurs * @param onCapturing Called when change capture status * @return promise of captured file url */ async startCapture(onProgress, onStopFailed, onCapturing) { if (onProgress) { this.notify.addNotify(NOTIFY_PROGRESS, event => { var _event$params; onProgress((_event$params = event.params) === null || _event$params === void 0 ? void 0 : _event$params.completion); }); } if (onStopFailed) { this.notify.addNotify(NOTIFY_STOP_ERROR, event => { onStopFailed(event.params); }); } if (onCapturing) { this.notify.addNotify(NOTIFY_CAPTURING, event => { var _event$params2; if ((_event$params2 = event.params) !== null && _event$params2 !== void 0 && _event$params2.status) { onCapturing(event.params.status); } }); } return new Promise(async (resolve, reject) => { await _NativeThetaClientReactNative.default.startCompositeIntervalCapture().then(result => { resolve(result ?? undefined); }).catch(error => { reject(error); }).finally(() => { this.notify.removeNotify(NOTIFY_PROGRESS); this.notify.removeNotify(NOTIFY_STOP_ERROR); this.notify.removeNotify(NOTIFY_CAPTURING); }); }); } /** * cancel interval composite shooting */ async cancelCapture() { return await _NativeThetaClientReactNative.default.cancelCompositeIntervalCapture(); } } /** * CompositeIntervalCaptureBuilder class */ exports.CompositeIntervalCapture = CompositeIntervalCapture; class CompositeIntervalCaptureBuilder extends _capture.CaptureBuilder { /** construct CompositeIntervalCaptureBuilder instance */ constructor(shootingTimeSec) { super(); this.interval = undefined; this.shootingTimeSec = shootingTimeSec; } /** * set interval of checking interval composite shooting status command * @param timeMillis interval * @returns CompositeIntervalCaptureBuilder */ setCheckStatusCommandInterval(timeMillis) { this.interval = timeMillis; return this; } /** * Set In-progress save interval for interval composite shooting (sec). * @param {interval} sec sec. * @return CompositeIntervalCaptureBuilder */ setCompositeShootingOutputInterval(sec) { this.options.compositeShootingOutputInterval = sec; return this; } /** * Builds an instance of a CompositeIntervalCapture that has all the combined * parameters of the Options that have been added to the Builder. * @return promise of CompositeIntervalCapture instance */ build() { let params = { ...this.options, // Cannot pass negative values in IOS, use objects _capture_interval: this.interval ?? -1 }; return new Promise(async (resolve, reject) => { try { await _NativeThetaClientReactNative.default.getCompositeIntervalCaptureBuilder(this.shootingTimeSec); await _NativeThetaClientReactNative.default.buildCompositeIntervalCapture(params); resolve(new CompositeIntervalCapture(_notifyController.NotifyController.instance)); } catch (error) { reject(error); } }); } } exports.CompositeIntervalCaptureBuilder = CompositeIntervalCaptureBuilder; //# sourceMappingURL=composite-interval-capture.js.map