UNPKG

theta-client-react-native

Version:

This library provides a way to control RICOH THETA using.

135 lines (129 loc) 4.41 kB
import { CaptureBuilder } from './capture'; import ThetaClientReactNative from '../NativeThetaClientReactNative'; import { NotifyController } from '../theta-repository/notify-controller'; const NOTIFY_PROGRESS = 'MULTI-BRACKET-PROGRESS'; const NOTIFY_STOP_ERROR = 'MULTI-BRACKET-STOP-ERROR'; const NOTIFY_CAPTURING = 'MULTI-BRACKET-CAPTURING'; /** * MultiBracketCapture class */ export class MultiBracketCapture { constructor(notify) { this.notify = notify; } /** * start multi bracket shooting * @param onProgress the block for multi bracket shooting onProgress * @param onStopFailed the block for error of cancelCapture * @param onCapturing Called when change capture status * @return promise of captured file urls */ 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 ThetaClientReactNative.startMultiBracketCapture().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 multi bracket shooting */ async cancelCapture() { return await ThetaClientReactNative.cancelMultiBracketCapture(); } } /** * MultiBracketCaptureBuilder class */ export class MultiBracketCaptureBuilder extends CaptureBuilder { /** construct MultiBracketCaptureBuilder instance */ constructor() { super(); this.interval = undefined; } /** * set interval of checking multi bracket shooting status command * @param timeMillis interval * @returns MultiBracketCaptureBuilder */ setCheckStatusCommandInterval(timeMillis) { this.interval = timeMillis; return this; } /** * Set bracket settings for multi bracket shooting * * Number of shots in multi bracket shooting * | | Min | Max | * | ---------------------- | --- | --- | * | THETA S | 2 | 13 | * | THETA SC | 2 | 13 | * | THETA V | 2 | 19 | * | THETA SC2 | 2 | 13 | * | THETA SC2 for business | 2 | 13 | * | THETA Z1 | 2 | 19 | * | THETA X | 2 | 13 | * * @param params array of bracket setting. Size must be the Number of shots in multi bracket shooting. * * For Theta SC2, S and SC, other settings than iso, shutterSpeed and * colorTemperature are ignored. * For Theta X, exposureProgram and exposureCompensation are ignored * so that always manual program. * For others than Theta Z1, aperture is ignored. * To setting parameters that are not specified, default values are used. * * @returns MultiBracketCaptureBuilder */ setBracketSettings(settings) { this.options.autoBracket = settings; return this; } /** * Builds an instance of a MultiBracketCapture that has all the combined * parameters of the Options that have been added to the Builder. * @return promise of MultiBracketCapture 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 ThetaClientReactNative.getMultiBracketCaptureBuilder(); await ThetaClientReactNative.buildMultiBracketCapture(params); resolve(new MultiBracketCapture(NotifyController.instance)); } catch (error) { reject(error); } }); } } //# sourceMappingURL=multi-bracket-capture.js.map