theta-client-react-native 1.9.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/ricoh360/thetaclientreactnative/Converter.kt +27 -0
  3. package/android/src/main/java/com/ricoh360/thetaclientreactnative/ThetaClientSdkModule.kt +94 -0
  4. package/ios/ConvertUtil.swift +22 -0
  5. package/ios/ThetaClientReactNative.m +3 -0
  6. package/ios/ThetaClientReactNative.swift +133 -9
  7. package/lib/commonjs/capture/burst-capture.js +13 -1
  8. package/lib/commonjs/capture/burst-capture.js.map +1 -1
  9. package/lib/commonjs/capture/capture.js +24 -1
  10. package/lib/commonjs/capture/capture.js.map +1 -1
  11. package/lib/commonjs/capture/composite-interval-capture.js +13 -1
  12. package/lib/commonjs/capture/composite-interval-capture.js.map +1 -1
  13. package/lib/commonjs/capture/continuous-capture.js +12 -1
  14. package/lib/commonjs/capture/continuous-capture.js.map +1 -1
  15. package/lib/commonjs/capture/limitless-interval-capture.js +29 -2
  16. package/lib/commonjs/capture/limitless-interval-capture.js.map +1 -1
  17. package/lib/commonjs/capture/multi-bracket-capture.js +13 -1
  18. package/lib/commonjs/capture/multi-bracket-capture.js.map +1 -1
  19. package/lib/commonjs/capture/photo-capture.js +34 -10
  20. package/lib/commonjs/capture/photo-capture.js.map +1 -1
  21. package/lib/commonjs/capture/shot-count-specified-interval-capture.js +12 -1
  22. package/lib/commonjs/capture/shot-count-specified-interval-capture.js.map +1 -1
  23. package/lib/commonjs/capture/time-shift-capture.js +12 -1
  24. package/lib/commonjs/capture/time-shift-capture.js.map +1 -1
  25. package/lib/commonjs/capture/video-capture.js +29 -2
  26. package/lib/commonjs/capture/video-capture.js.map +1 -1
  27. package/lib/commonjs/index.js.map +1 -1
  28. package/lib/commonjs/theta-repository/options/option-file-format.js +20 -0
  29. package/lib/commonjs/theta-repository/options/option-file-format.js.map +1 -1
  30. package/lib/commonjs/theta-repository/theta-repository.js +11 -0
  31. package/lib/commonjs/theta-repository/theta-repository.js.map +1 -1
  32. package/lib/commonjs/theta-repository/theta-state/capture-status.js +32 -0
  33. package/lib/commonjs/theta-repository/theta-state/capture-status.js.map +1 -0
  34. package/lib/commonjs/theta-repository/theta-state/index.js +11 -0
  35. package/lib/commonjs/theta-repository/theta-state/index.js.map +1 -1
  36. package/lib/commonjs/theta-repository/theta-state/theta-state.js +1 -23
  37. package/lib/commonjs/theta-repository/theta-state/theta-state.js.map +1 -1
  38. package/lib/module/capture/burst-capture.js +13 -1
  39. package/lib/module/capture/burst-capture.js.map +1 -1
  40. package/lib/module/capture/capture.js +22 -0
  41. package/lib/module/capture/capture.js.map +1 -1
  42. package/lib/module/capture/composite-interval-capture.js +13 -1
  43. package/lib/module/capture/composite-interval-capture.js.map +1 -1
  44. package/lib/module/capture/continuous-capture.js +12 -1
  45. package/lib/module/capture/continuous-capture.js.map +1 -1
  46. package/lib/module/capture/limitless-interval-capture.js +29 -2
  47. package/lib/module/capture/limitless-interval-capture.js.map +1 -1
  48. package/lib/module/capture/multi-bracket-capture.js +13 -1
  49. package/lib/module/capture/multi-bracket-capture.js.map +1 -1
  50. package/lib/module/capture/photo-capture.js +35 -11
  51. package/lib/module/capture/photo-capture.js.map +1 -1
  52. package/lib/module/capture/shot-count-specified-interval-capture.js +12 -1
  53. package/lib/module/capture/shot-count-specified-interval-capture.js.map +1 -1
  54. package/lib/module/capture/time-shift-capture.js +12 -1
  55. package/lib/module/capture/time-shift-capture.js.map +1 -1
  56. package/lib/module/capture/video-capture.js +29 -2
  57. package/lib/module/capture/video-capture.js.map +1 -1
  58. package/lib/module/index.js.map +1 -1
  59. package/lib/module/theta-repository/options/option-file-format.js +20 -0
  60. package/lib/module/theta-repository/options/option-file-format.js.map +1 -1
  61. package/lib/module/theta-repository/theta-repository.js +10 -0
  62. package/lib/module/theta-repository/theta-repository.js.map +1 -1
  63. package/lib/module/theta-repository/theta-state/capture-status.js +26 -0
  64. package/lib/module/theta-repository/theta-state/capture-status.js.map +1 -0
  65. package/lib/module/theta-repository/theta-state/index.js +1 -0
  66. package/lib/module/theta-repository/theta-state/index.js.map +1 -1
  67. package/lib/module/theta-repository/theta-state/theta-state.js +0 -22
  68. package/lib/module/theta-repository/theta-state/theta-state.js.map +1 -1
  69. package/lib/typescript/capture/burst-capture.d.ts +4 -2
  70. package/lib/typescript/capture/burst-capture.d.ts.map +1 -1
  71. package/lib/typescript/capture/capture.d.ts +18 -1
  72. package/lib/typescript/capture/capture.d.ts.map +1 -1
  73. package/lib/typescript/capture/composite-interval-capture.d.ts +4 -2
  74. package/lib/typescript/capture/composite-interval-capture.d.ts.map +1 -1
  75. package/lib/typescript/capture/continuous-capture.d.ts +3 -2
  76. package/lib/typescript/capture/continuous-capture.d.ts.map +1 -1
  77. package/lib/typescript/capture/limitless-interval-capture.d.ts +10 -2
  78. package/lib/typescript/capture/limitless-interval-capture.d.ts.map +1 -1
  79. package/lib/typescript/capture/multi-bracket-capture.d.ts +5 -3
  80. package/lib/typescript/capture/multi-bracket-capture.d.ts.map +1 -1
  81. package/lib/typescript/capture/photo-capture.d.ts +15 -8
  82. package/lib/typescript/capture/photo-capture.d.ts.map +1 -1
  83. package/lib/typescript/capture/shot-count-specified-interval-capture.d.ts +3 -2
  84. package/lib/typescript/capture/shot-count-specified-interval-capture.d.ts.map +1 -1
  85. package/lib/typescript/capture/time-shift-capture.d.ts +3 -2
  86. package/lib/typescript/capture/time-shift-capture.d.ts.map +1 -1
  87. package/lib/typescript/capture/video-capture.d.ts +10 -2
  88. package/lib/typescript/capture/video-capture.d.ts.map +1 -1
  89. package/lib/typescript/theta-repository/options/option-file-format.d.ts +30 -0
  90. package/lib/typescript/theta-repository/options/option-file-format.d.ts.map +1 -1
  91. package/lib/typescript/theta-repository/theta-repository.d.ts +7 -0
  92. package/lib/typescript/theta-repository/theta-repository.d.ts.map +1 -1
  93. package/lib/typescript/theta-repository/theta-state/capture-status.d.ts +26 -0
  94. package/lib/typescript/theta-repository/theta-state/capture-status.d.ts.map +1 -0
  95. package/lib/typescript/theta-repository/theta-state/index.d.ts +1 -0
  96. package/lib/typescript/theta-repository/theta-state/index.d.ts.map +1 -1
  97. package/lib/typescript/theta-repository/theta-state/theta-state.d.ts +1 -21
  98. package/lib/typescript/theta-repository/theta-state/theta-state.d.ts.map +1 -1
  99. package/package.json +2 -2
  100. package/src/capture/burst-capture.ts +20 -2
  101. package/src/capture/capture.ts +27 -0
  102. package/src/capture/composite-interval-capture.ts +20 -2
  103. package/src/capture/continuous-capture.ts +19 -2
  104. package/src/capture/limitless-interval-capture.ts +40 -5
  105. package/src/capture/multi-bracket-capture.ts +21 -3
  106. package/src/capture/photo-capture.ts +50 -15
  107. package/src/capture/shot-count-specified-interval-capture.ts +19 -2
  108. package/src/capture/time-shift-capture.ts +19 -2
  109. package/src/capture/video-capture.ts +38 -3
  110. package/src/theta-repository/options/option-file-format.ts +20 -0
  111. package/src/theta-repository/theta-repository.ts +10 -0
  112. package/src/theta-repository/theta-state/capture-status.ts +27 -0
  113. package/src/theta-repository/theta-state/index.ts +1 -0
  114. package/src/theta-repository/theta-state/theta-state.ts +1 -24
  115. package/theta-client-react-native.podspec +1 -1
@@ -1,4 +1,4 @@
1
- import { CaptureBuilder } from './capture';
1
+ import { CaptureBuilder, CapturingStatusEnum } from './capture';
2
2
  import { NativeModules } from 'react-native';
3
3
  import {
4
4
  BaseNotify,
@@ -17,6 +17,7 @@ const ThetaClientReactNative = NativeModules.ThetaClientReactNative;
17
17
 
18
18
  const NOTIFY_PROGRESS = 'BURST-PROGRESS';
19
19
  const NOTIFY_STOP_ERROR = 'BURST-STOP-ERROR';
20
+ const NOTIFY_CAPTURING = 'BURST-CAPTURING';
20
21
 
21
22
  interface CaptureProgressNotify extends BaseNotify {
22
23
  params?: {
@@ -30,6 +31,12 @@ interface CaptureStopErrorNotify extends BaseNotify {
30
31
  };
31
32
  }
32
33
 
34
+ interface CapturingNotify extends BaseNotify {
35
+ params?: {
36
+ status: CapturingStatusEnum;
37
+ };
38
+ }
39
+
33
40
  /**
34
41
  * BurstCapture class
35
42
  */
@@ -41,11 +48,14 @@ export class BurstCapture {
41
48
  /**
42
49
  * start burst shooting
43
50
  * @param onProgress the block for burst shooting onProgress
51
+ * @param onStopFailed Called when stopCapture error occurs
52
+ * @param onCapturing Called when change capture status
44
53
  * @return promise of captured file url
45
54
  */
46
55
  async startCapture(
47
56
  onProgress?: (completion?: number) => void,
48
- onStopFailed?: (error: any) => void
57
+ onStopFailed?: (error: any) => void,
58
+ onCapturing?: (status: CapturingStatusEnum) => void
49
59
  ): Promise<string[] | undefined> {
50
60
  if (onProgress) {
51
61
  this.notify.addNotify(NOTIFY_PROGRESS, (event: CaptureProgressNotify) => {
@@ -60,6 +70,13 @@ export class BurstCapture {
60
70
  }
61
71
  );
62
72
  }
73
+ if (onCapturing) {
74
+ this.notify.addNotify(NOTIFY_CAPTURING, (event: CapturingNotify) => {
75
+ if (event.params?.status) {
76
+ onCapturing(event.params.status);
77
+ }
78
+ });
79
+ }
63
80
 
64
81
  return new Promise<string[] | undefined>(async (resolve, reject) => {
65
82
  await ThetaClientReactNative.startBurstCapture()
@@ -72,6 +89,7 @@ export class BurstCapture {
72
89
  .finally(() => {
73
90
  this.notify.removeNotify(NOTIFY_PROGRESS);
74
91
  this.notify.removeNotify(NOTIFY_STOP_ERROR);
92
+ this.notify.removeNotify(NOTIFY_CAPTURING);
75
93
  });
76
94
  });
77
95
  }
@@ -8,6 +8,7 @@ import type {
8
8
  IsoAutoHighLimitEnum,
9
9
  IsoEnum,
10
10
  Options,
11
+ PhotoFileFormatEnum,
11
12
  WhiteBalanceEnum,
12
13
  } from '../theta-repository/options';
13
14
 
@@ -122,3 +123,29 @@ export abstract class CaptureBuilder<T extends CaptureBuilder<T>> {
122
123
  return this as unknown as T;
123
124
  }
124
125
  }
126
+
127
+ /** Capturing status */
128
+ export const CapturingStatusEnum = {
129
+ /** Capture in progress */
130
+ CAPTURING: 'CAPTURING',
131
+ /** Self-timer in progress */
132
+ SELF_TIMER_COUNTDOWN: 'SELF_TIMER_COUNTDOWN',
133
+ } as const;
134
+
135
+ /** type definition of CapturingStatusEnum */
136
+ export type CapturingStatusEnum =
137
+ (typeof CapturingStatusEnum)[keyof typeof CapturingStatusEnum];
138
+
139
+ export class PhotoCaptureBuilderBase<
140
+ T extends PhotoCaptureBuilderBase<T>
141
+ > extends CaptureBuilder<T> {
142
+ /**
143
+ * Set photo file format.
144
+ * @param {PhotoFileFormatEnum} fileFormat Photo file format to set
145
+ * @return PhotoCaptureBuilder
146
+ */
147
+ setFileFormat(fileFormat: PhotoFileFormatEnum): T {
148
+ this.options.fileFormat = fileFormat;
149
+ return this as unknown as T;
150
+ }
151
+ }
@@ -1,4 +1,4 @@
1
- import { CaptureBuilder } from './capture';
1
+ import { CaptureBuilder, CapturingStatusEnum } from './capture';
2
2
  import { NativeModules } from 'react-native';
3
3
  import {
4
4
  BaseNotify,
@@ -8,6 +8,7 @@ const ThetaClientReactNative = NativeModules.ThetaClientReactNative;
8
8
 
9
9
  const NOTIFY_PROGRESS = 'COMPOSITE-INTERVAL-PROGRESS';
10
10
  const NOTIFY_STOP_ERROR = 'COMPOSITE-INTERVAL-STOP-ERROR';
11
+ const NOTIFY_CAPTURING = 'COMPOSITE-INTERVAL-CAPTURING';
11
12
 
12
13
  interface CaptureProgressNotify extends BaseNotify {
13
14
  params?: {
@@ -21,6 +22,12 @@ interface CaptureStopErrorNotify extends BaseNotify {
21
22
  };
22
23
  }
23
24
 
25
+ interface CapturingNotify extends BaseNotify {
26
+ params?: {
27
+ status: CapturingStatusEnum;
28
+ };
29
+ }
30
+
24
31
  /**
25
32
  * CompositeIntervalCapture class
26
33
  */
@@ -32,11 +39,14 @@ export class CompositeIntervalCapture {
32
39
  /**
33
40
  * start interval composite shooting
34
41
  * @param onProgress the block for interval composite shooting onProgress
42
+ * @param onStopFailed Called when stopCapture error occurs
43
+ * @param onCapturing Called when change capture status
35
44
  * @return promise of captured file url
36
45
  */
37
46
  async startCapture(
38
47
  onProgress?: (completion?: number) => void,
39
- onStopFailed?: (error: any) => void
48
+ onStopFailed?: (error: any) => void,
49
+ onCapturing?: (status: CapturingStatusEnum) => void
40
50
  ): Promise<string[] | undefined> {
41
51
  if (onProgress) {
42
52
  this.notify.addNotify(NOTIFY_PROGRESS, (event: CaptureProgressNotify) => {
@@ -51,6 +61,13 @@ export class CompositeIntervalCapture {
51
61
  }
52
62
  );
53
63
  }
64
+ if (onCapturing) {
65
+ this.notify.addNotify(NOTIFY_CAPTURING, (event: CapturingNotify) => {
66
+ if (event.params?.status) {
67
+ onCapturing(event.params.status);
68
+ }
69
+ });
70
+ }
54
71
 
55
72
  return new Promise<string[] | undefined>(async (resolve, reject) => {
56
73
  await ThetaClientReactNative.startCompositeIntervalCapture()
@@ -63,6 +80,7 @@ export class CompositeIntervalCapture {
63
80
  .finally(() => {
64
81
  this.notify.removeNotify(NOTIFY_PROGRESS);
65
82
  this.notify.removeNotify(NOTIFY_STOP_ERROR);
83
+ this.notify.removeNotify(NOTIFY_CAPTURING);
66
84
  });
67
85
  });
68
86
  }
@@ -1,4 +1,4 @@
1
- import { CaptureBuilder } from './capture';
1
+ import { CaptureBuilder, CapturingStatusEnum } from './capture';
2
2
  import { NativeModules } from 'react-native';
3
3
  import {
4
4
  BaseNotify,
@@ -13,6 +13,7 @@ import { getOptions } from '../theta-repository';
13
13
  const ThetaClientReactNative = NativeModules.ThetaClientReactNative;
14
14
 
15
15
  const NOTIFY_PROGRESS = 'CONTINUOUS-PROGRESS';
16
+ const NOTIFY_CAPTURING = 'CONTINUOUS-CAPTURING';
16
17
 
17
18
  interface CaptureProgressNotify extends BaseNotify {
18
19
  params?: {
@@ -20,6 +21,12 @@ interface CaptureProgressNotify extends BaseNotify {
20
21
  };
21
22
  }
22
23
 
24
+ interface CapturingNotify extends BaseNotify {
25
+ params?: {
26
+ status: CapturingStatusEnum;
27
+ };
28
+ }
29
+
23
30
  /**
24
31
  * ContinuousCapture class
25
32
  */
@@ -31,16 +38,25 @@ export class ContinuousCapture {
31
38
  /**
32
39
  * start continuous shooting
33
40
  * @param onProgress the block for continuous shooting onProgress
41
+ * @param onCapturing Called when change capture status
34
42
  * @return promise of captured file url
35
43
  */
36
44
  async startCapture(
37
- onProgress?: (completion?: number) => void
45
+ onProgress?: (completion?: number) => void,
46
+ onCapturing?: (status: CapturingStatusEnum) => void
38
47
  ): Promise<string[] | undefined> {
39
48
  if (onProgress) {
40
49
  this.notify.addNotify(NOTIFY_PROGRESS, (event: CaptureProgressNotify) => {
41
50
  onProgress(event.params?.completion);
42
51
  });
43
52
  }
53
+ if (onCapturing) {
54
+ this.notify.addNotify(NOTIFY_CAPTURING, (event: CapturingNotify) => {
55
+ if (event.params?.status) {
56
+ onCapturing(event.params.status);
57
+ }
58
+ });
59
+ }
44
60
 
45
61
  return new Promise<string[] | undefined>(async (resolve, reject) => {
46
62
  await ThetaClientReactNative.startContinuousCapture()
@@ -52,6 +68,7 @@ export class ContinuousCapture {
52
68
  })
53
69
  .finally(() => {
54
70
  this.notify.removeNotify(NOTIFY_PROGRESS);
71
+ this.notify.removeNotify(NOTIFY_CAPTURING);
55
72
  });
56
73
  });
57
74
  }
@@ -1,4 +1,4 @@
1
- import { CaptureBuilder } from './capture';
1
+ import { CaptureBuilder, CapturingStatusEnum } from './capture';
2
2
  import { NativeModules } from 'react-native';
3
3
  import {
4
4
  BaseNotify,
@@ -7,6 +7,7 @@ import {
7
7
  const ThetaClientReactNative = NativeModules.ThetaClientReactNative;
8
8
 
9
9
  const NOTIFY_NAME = 'LIMITLESS-INTERVAL-CAPTURE-STOP-ERROR';
10
+ const NOTIFY_CAPTURING = 'LIMITLESS-INTERVAL-CAPTURE-CAPTURING';
10
11
 
11
12
  interface CaptureStopErrorNotify extends BaseNotify {
12
13
  params?: {
@@ -14,6 +15,12 @@ interface CaptureStopErrorNotify extends BaseNotify {
14
15
  };
15
16
  }
16
17
 
18
+ interface CapturingNotify extends BaseNotify {
19
+ params?: {
20
+ status: CapturingStatusEnum;
21
+ };
22
+ }
23
+
17
24
  /**
18
25
  * LimitlessIntervalCapture class
19
26
  */
@@ -26,16 +33,25 @@ export class LimitlessIntervalCapture {
26
33
  /**
27
34
  * start limitless interval capture
28
35
  * @param onStopFailed the block for error of stopCapture
36
+ * @param onCapturing Called when change capture status
29
37
  * @return promise of captured file url
30
38
  */
31
39
  startCapture(
32
- onStopFailed?: (error: any) => void
40
+ onStopFailed?: (error: any) => void,
41
+ onCapturing?: (status: CapturingStatusEnum) => void
33
42
  ): Promise<string[] | undefined> {
34
43
  if (onStopFailed) {
35
44
  this.notify.addNotify(NOTIFY_NAME, (event: CaptureStopErrorNotify) => {
36
45
  onStopFailed(event.params);
37
46
  });
38
47
  }
48
+ if (onCapturing) {
49
+ this.notify.addNotify(NOTIFY_CAPTURING, (event: CapturingNotify) => {
50
+ if (event.params?.status) {
51
+ onCapturing(event.params.status);
52
+ }
53
+ });
54
+ }
39
55
  return new Promise<string[] | undefined>(async (resolve, reject) => {
40
56
  await ThetaClientReactNative.startLimitlessIntervalCapture()
41
57
  .then((result?: string[]) => {
@@ -46,6 +62,7 @@ export class LimitlessIntervalCapture {
46
62
  })
47
63
  .finally(() => {
48
64
  this.notify.removeNotify(NOTIFY_NAME);
65
+ this.notify.removeNotify(NOTIFY_CAPTURING);
49
66
  });
50
67
  });
51
68
  }
@@ -62,9 +79,24 @@ export class LimitlessIntervalCapture {
62
79
  * LimitlessIntervalCaptureBuilder class
63
80
  */
64
81
  export class LimitlessIntervalCaptureBuilder extends CaptureBuilder<LimitlessIntervalCaptureBuilder> {
82
+ interval?: number;
83
+
65
84
  /** construct LimitlessIntervalCaptureBuilder instance */
66
85
  constructor() {
67
86
  super();
87
+ this.interval = undefined;
88
+ }
89
+
90
+ /**
91
+ * set interval of checking continuous shooting status command
92
+ * @param timeMillis interval
93
+ * @returns LimitlessIntervalCaptureBuilder
94
+ */
95
+ setCheckStatusCommandInterval(
96
+ timeMillis: number
97
+ ): LimitlessIntervalCaptureBuilder {
98
+ this.interval = timeMillis;
99
+ return this;
68
100
  }
69
101
 
70
102
  /**
@@ -84,12 +116,15 @@ export class LimitlessIntervalCaptureBuilder extends CaptureBuilder<LimitlessInt
84
116
  * @return promise of LimitlessIntervalCapture instance
85
117
  */
86
118
  build(): Promise<LimitlessIntervalCapture> {
119
+ let params = {
120
+ ...this.options,
121
+ // Cannot pass negative values in IOS, use objects
122
+ _capture_interval: this.interval ?? -1,
123
+ };
87
124
  return new Promise<LimitlessIntervalCapture>(async (resolve, reject) => {
88
125
  try {
89
126
  await ThetaClientReactNative.getLimitlessIntervalCaptureBuilder();
90
- await ThetaClientReactNative.buildLimitlessIntervalCapture(
91
- this.options
92
- );
127
+ await ThetaClientReactNative.buildLimitlessIntervalCapture(params);
93
128
  resolve(new LimitlessIntervalCapture(NotifyController.instance));
94
129
  } catch (error) {
95
130
  reject(error);
@@ -1,14 +1,15 @@
1
- import { CaptureBuilder } from './capture';
1
+ import { CaptureBuilder, CapturingStatusEnum } from './capture';
2
2
  import { NativeModules } from 'react-native';
3
3
  import {
4
4
  BaseNotify,
5
5
  NotifyController,
6
6
  } from '../theta-repository/notify-controller';
7
- import type { BracketSetting } from 'src/theta-repository/options';
7
+ import type { BracketSetting } from '../theta-repository/options';
8
8
  const ThetaClientReactNative = NativeModules.ThetaClientReactNative;
9
9
 
10
10
  const NOTIFY_PROGRESS = 'MULTI-BRACKET-PROGRESS';
11
11
  const NOTIFY_STOP_ERROR = 'MULTI-BRACKET-STOP-ERROR';
12
+ const NOTIFY_CAPTURING = 'MULTI-BRACKET-CAPTURING';
12
13
 
13
14
  interface CaptureProgressNotify extends BaseNotify {
14
15
  params?: {
@@ -22,6 +23,12 @@ interface CaptureStopErrorNotify extends BaseNotify {
22
23
  };
23
24
  }
24
25
 
26
+ interface CapturingNotify extends BaseNotify {
27
+ params?: {
28
+ status: CapturingStatusEnum;
29
+ };
30
+ }
31
+
25
32
  /**
26
33
  * MultiBracketCapture class
27
34
  */
@@ -34,11 +41,14 @@ export class MultiBracketCapture {
34
41
  /**
35
42
  * start multi bracket shooting
36
43
  * @param onProgress the block for multi bracket shooting onProgress
44
+ * @param onStopFailed the block for error of cancelCapture
45
+ * @param onCapturing Called when change capture status
37
46
  * @return promise of captured file urls
38
47
  */
39
48
  async startCapture(
40
49
  onProgress?: (completion?: number) => void,
41
- onStopFailed?: (error: any) => void
50
+ onStopFailed?: (error: any) => void,
51
+ onCapturing?: (status: CapturingStatusEnum) => void
42
52
  ): Promise<string[] | undefined> {
43
53
  if (onProgress) {
44
54
  this.notify.addNotify(NOTIFY_PROGRESS, (event: CaptureProgressNotify) => {
@@ -53,6 +63,13 @@ export class MultiBracketCapture {
53
63
  }
54
64
  );
55
65
  }
66
+ if (onCapturing) {
67
+ this.notify.addNotify(NOTIFY_CAPTURING, (event: CapturingNotify) => {
68
+ if (event.params?.status) {
69
+ onCapturing(event.params.status);
70
+ }
71
+ });
72
+ }
56
73
 
57
74
  return new Promise<string[] | undefined>(async (resolve, reject) => {
58
75
  await ThetaClientReactNative.startMultiBracketCapture()
@@ -65,6 +82,7 @@ export class MultiBracketCapture {
65
82
  .finally(() => {
66
83
  this.notify.removeNotify(NOTIFY_PROGRESS);
67
84
  this.notify.removeNotify(NOTIFY_STOP_ERROR);
85
+ this.notify.removeNotify(NOTIFY_CAPTURING);
68
86
  });
69
87
  });
70
88
  }
@@ -1,26 +1,53 @@
1
- import { CaptureBuilder } from './capture';
2
- import type {
3
- FilterEnum,
4
- PhotoFileFormatEnum,
5
- PresetEnum,
6
- } from '../theta-repository/options';
1
+ import { CapturingStatusEnum, PhotoCaptureBuilderBase } from './capture';
2
+ import type { FilterEnum, PresetEnum } from '../theta-repository/options';
7
3
 
8
4
  import { NativeModules } from 'react-native';
5
+ import {
6
+ BaseNotify,
7
+ NotifyController,
8
+ } from '../theta-repository/notify-controller';
9
9
  const ThetaClientReactNative = NativeModules.ThetaClientReactNative;
10
10
 
11
+ const NOTIFY_CAPTURING = 'PHOTO-CAPTURING';
12
+
13
+ interface CapturingNotify extends BaseNotify {
14
+ params?: {
15
+ status: CapturingStatusEnum;
16
+ };
17
+ }
18
+
11
19
  /**
12
20
  * PhotoCapture class
13
21
  */
14
22
  export class PhotoCapture {
23
+ notify: NotifyController;
24
+ constructor(notify: NotifyController) {
25
+ this.notify = notify;
26
+ }
27
+
15
28
  /**
29
+ * Take a picture
30
+ *
31
+ * @param onCapturing Called when change capture status
16
32
  * @return promise of token file url
17
33
  */
18
- async takePicture(): Promise<string | undefined> {
34
+ async takePicture(
35
+ onCapturing?: (status: CapturingStatusEnum) => void
36
+ ): Promise<string | undefined> {
37
+ if (onCapturing) {
38
+ this.notify.addNotify(NOTIFY_CAPTURING, (event: CapturingNotify) => {
39
+ if (event.params?.status) {
40
+ onCapturing(event.params.status);
41
+ }
42
+ });
43
+ }
19
44
  try {
20
45
  const fileUrl = await ThetaClientReactNative.takePicture();
21
46
  return fileUrl ?? undefined;
22
47
  } catch (error) {
23
48
  throw error;
49
+ } finally {
50
+ this.notify.removeNotify(NOTIFY_CAPTURING);
24
51
  }
25
52
  }
26
53
  }
@@ -28,19 +55,22 @@ export class PhotoCapture {
28
55
  /**
29
56
  * PhotoCaptureBaseBuilder class
30
57
  */
31
- export class PhotoCaptureBuilder extends CaptureBuilder<PhotoCaptureBuilder> {
58
+ export class PhotoCaptureBuilder extends PhotoCaptureBuilderBase<PhotoCaptureBuilder> {
59
+ interval?: number;
60
+
32
61
  /** construct PhotoCaptureBuilder instance */
33
62
  constructor() {
34
63
  super();
64
+ this.interval = undefined;
35
65
  }
36
66
 
37
67
  /**
38
- * Set photo file format.
39
- * @param {PhotoFileFormatEnum} fileFormat Photo file format to set
40
- * @return PhotoCaptureBuilder
68
+ * set interval of checking take picture status command
69
+ * @param timeMillis interval
70
+ * @returns PhotoCaptureBuilder
41
71
  */
42
- setFileFormat(fileFormat: PhotoFileFormatEnum): PhotoCaptureBuilder {
43
- this.options.fileFormat = fileFormat;
72
+ setCheckStatusCommandInterval(timeMillis: number): PhotoCaptureBuilder {
73
+ this.interval = timeMillis;
44
74
  return this;
45
75
  }
46
76
 
@@ -71,11 +101,16 @@ export class PhotoCaptureBuilder extends CaptureBuilder<PhotoCaptureBuilder> {
71
101
  * @return promise of PhotoCapture instance
72
102
  */
73
103
  build(): Promise<PhotoCapture> {
104
+ let params = {
105
+ ...this.options,
106
+ // Cannot pass negative values in IOS, use objects
107
+ _capture_interval: this.interval ?? -1,
108
+ };
74
109
  return new Promise<PhotoCapture>(async (resolve, reject) => {
75
110
  try {
76
111
  await ThetaClientReactNative.getPhotoCaptureBuilder();
77
- await ThetaClientReactNative.buildPhotoCapture(this.options);
78
- resolve(new PhotoCapture());
112
+ await ThetaClientReactNative.buildPhotoCapture(params);
113
+ resolve(new PhotoCapture(NotifyController.instance));
79
114
  } catch (error) {
80
115
  reject(error);
81
116
  }
@@ -1,4 +1,4 @@
1
- import { CaptureBuilder } from './capture';
1
+ import { CaptureBuilder, CapturingStatusEnum } from './capture';
2
2
  import { NativeModules } from 'react-native';
3
3
  import {
4
4
  BaseNotify,
@@ -8,6 +8,7 @@ const ThetaClientReactNative = NativeModules.ThetaClientReactNative;
8
8
 
9
9
  const NOTIFY_PROGRESS = 'SHOT-COUNT-SPECIFIED-INTERVAL-PROGRESS';
10
10
  const NOTIFY_STOP_ERROR = 'SHOT-COUNT-SPECIFIED-INTERVAL-STOP-ERROR';
11
+ const NOTIFY_CAPTURING = 'SHOT-COUNT-SPECIFIED-INTERVAL-CAPTURING';
11
12
 
12
13
  interface CaptureProgressNotify extends BaseNotify {
13
14
  params?: {
@@ -21,6 +22,12 @@ interface CaptureStopErrorNotify extends BaseNotify {
21
22
  };
22
23
  }
23
24
 
25
+ interface CapturingNotify extends BaseNotify {
26
+ params?: {
27
+ status: CapturingStatusEnum;
28
+ };
29
+ }
30
+
24
31
  /**
25
32
  * ShotCountSpecifiedIntervalCapture class
26
33
  */
@@ -33,11 +40,13 @@ export class ShotCountSpecifiedIntervalCapture {
33
40
  * start interval shooting with the shot count specified
34
41
  * @param onProgress the block for interval shooting with the shot count specified onProgress
35
42
  * @param onStopFailed the block for error of cancelCapture
43
+ * @param onCapturing Called when change capture status
36
44
  * @return promise of captured file url
37
45
  */
38
46
  async startCapture(
39
47
  onProgress?: (completion?: number) => void,
40
- onStopFailed?: (error: any) => void
48
+ onStopFailed?: (error: any) => void,
49
+ onCapturing?: (status: CapturingStatusEnum) => void
41
50
  ): Promise<string[] | undefined> {
42
51
  if (onProgress) {
43
52
  this.notify.addNotify(NOTIFY_PROGRESS, (event: CaptureProgressNotify) => {
@@ -52,6 +61,13 @@ export class ShotCountSpecifiedIntervalCapture {
52
61
  }
53
62
  );
54
63
  }
64
+ if (onCapturing) {
65
+ this.notify.addNotify(NOTIFY_CAPTURING, (event: CapturingNotify) => {
66
+ if (event.params?.status) {
67
+ onCapturing(event.params.status);
68
+ }
69
+ });
70
+ }
55
71
 
56
72
  return new Promise<string[] | undefined>(async (resolve, reject) => {
57
73
  await ThetaClientReactNative.startShotCountSpecifiedIntervalCapture()
@@ -64,6 +80,7 @@ export class ShotCountSpecifiedIntervalCapture {
64
80
  .finally(() => {
65
81
  this.notify.removeNotify(NOTIFY_PROGRESS);
66
82
  this.notify.removeNotify(NOTIFY_STOP_ERROR);
83
+ this.notify.removeNotify(NOTIFY_CAPTURING);
67
84
  });
68
85
  });
69
86
  }
@@ -1,4 +1,4 @@
1
- import { CaptureBuilder } from './capture';
1
+ import { CaptureBuilder, CapturingStatusEnum } from './capture';
2
2
  import { NativeModules } from 'react-native';
3
3
  import type { TimeShiftIntervalEnum } from '../theta-repository/options';
4
4
  import {
@@ -9,6 +9,7 @@ const ThetaClientReactNative = NativeModules.ThetaClientReactNative;
9
9
 
10
10
  const NOTIFY_NAME = 'TIME-SHIFT-PROGRESS';
11
11
  const NOTIFY_STOP_ERROR = 'TIME-SHIFT-STOP-ERROR';
12
+ const NOTIFY_CAPTURING = 'TIME-SHIFT-CAPTURING';
12
13
 
13
14
  interface CaptureProgressNotify extends BaseNotify {
14
15
  params?: {
@@ -22,6 +23,12 @@ interface CaptureStopErrorNotify extends BaseNotify {
22
23
  };
23
24
  }
24
25
 
26
+ interface CapturingNotify extends BaseNotify {
27
+ params?: {
28
+ status: CapturingStatusEnum;
29
+ };
30
+ }
31
+
25
32
  /**
26
33
  * TimeShiftCapture class
27
34
  */
@@ -34,11 +41,13 @@ export class TimeShiftCapture {
34
41
  * start time-shift
35
42
  * @param onProgress the block for time-shift onProgress
36
43
  * @param onStopFailed the block for error of cancelCapture
44
+ * @param onCapturing Called when change capture status
37
45
  * @return promise of captured file url
38
46
  */
39
47
  async startCapture(
40
48
  onProgress?: (completion?: number) => void,
41
- onStopFailed?: (error: any) => void
49
+ onStopFailed?: (error: any) => void,
50
+ onCapturing?: (status: CapturingStatusEnum) => void
42
51
  ): Promise<string | undefined> {
43
52
  if (onProgress) {
44
53
  this.notify.addNotify(NOTIFY_NAME, (event: CaptureProgressNotify) => {
@@ -53,6 +62,13 @@ export class TimeShiftCapture {
53
62
  }
54
63
  );
55
64
  }
65
+ if (onCapturing) {
66
+ this.notify.addNotify(NOTIFY_CAPTURING, (event: CapturingNotify) => {
67
+ if (event.params?.status) {
68
+ onCapturing(event.params.status);
69
+ }
70
+ });
71
+ }
56
72
 
57
73
  return new Promise<string | undefined>(async (resolve, reject) => {
58
74
  await ThetaClientReactNative.startTimeShiftCapture()
@@ -65,6 +81,7 @@ export class TimeShiftCapture {
65
81
  .finally(() => {
66
82
  this.notify.removeNotify(NOTIFY_NAME);
67
83
  this.notify.removeNotify(NOTIFY_STOP_ERROR);
84
+ this.notify.removeNotify(NOTIFY_CAPTURING);
68
85
  });
69
86
  });
70
87
  }