theta-client-react-native
Version:
This library provides a way to control RICOH THETA using.
124 lines (118 loc) • 4.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ShotCountSpecifiedIntervalCaptureBuilder = exports.ShotCountSpecifiedIntervalCapture = 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 = 'SHOT-COUNT-SPECIFIED-INTERVAL-PROGRESS';
const NOTIFY_STOP_ERROR = 'SHOT-COUNT-SPECIFIED-INTERVAL-STOP-ERROR';
const NOTIFY_CAPTURING = 'SHOT-COUNT-SPECIFIED-INTERVAL-CAPTURING';
/**
* ShotCountSpecifiedIntervalCapture class
*/
class ShotCountSpecifiedIntervalCapture {
constructor(notify) {
this.notify = notify;
}
/**
* start interval shooting with the shot count specified
* @param onProgress the block for interval shooting with the shot count specified onProgress
* @param onStopFailed the block for error of cancelCapture
* @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.startShotCountSpecifiedIntervalCapture().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 shooting with the shot count specified
*/
async cancelCapture() {
return await _NativeThetaClientReactNative.default.cancelShotCountSpecifiedIntervalCapture();
}
}
/**
* ShotCountSpecifiedIntervalCaptureBuilder class
*/
exports.ShotCountSpecifiedIntervalCapture = ShotCountSpecifiedIntervalCapture;
class ShotCountSpecifiedIntervalCaptureBuilder extends _capture.CaptureBuilder {
/** construct ShotCountSpecifiedIntervalCaptureBuilder instance */
constructor(shotCount) {
super();
this.interval = undefined;
this.shotCount = shotCount;
}
/**
* set interval of checking interval shooting with the shot count specified status command
* @param timeMillis interval
* @returns ShotCountSpecifiedIntervalCaptureBuilder
*/
setCheckStatusCommandInterval(timeMillis) {
this.interval = timeMillis;
return this;
}
/**
* Set shooting interval (sec.) for interval shooting.
* @param {interval} interval sec.
* @return ShotCountSpecifiedIntervalCaptureBuilder
*/
setCaptureInterval(interval) {
this.options.captureInterval = interval;
return this;
}
/**
* Builds an instance of a ShotCountSpecifiedIntervalCapture that has all the combined
* parameters of the Options that have been added to the Builder.
* @return promise of ShotCountSpecifiedIntervalCapture 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.getShotCountSpecifiedIntervalCaptureBuilder(this.shotCount);
await _NativeThetaClientReactNative.default.buildShotCountSpecifiedIntervalCapture(params);
resolve(new ShotCountSpecifiedIntervalCapture(_notifyController.NotifyController.instance));
} catch (error) {
reject(error);
}
});
}
}
exports.ShotCountSpecifiedIntervalCaptureBuilder = ShotCountSpecifiedIntervalCaptureBuilder;
//# sourceMappingURL=shot-count-specified-interval-capture.js.map