@capgo/camera-preview 8.4.7 → 8.5.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.
@@ -25,7 +25,8 @@ public class CameraSessionConfiguration {
25
25
  private final boolean enableVideoMode;
26
26
  private float targetZoom = 1.0f;
27
27
  private boolean isCentered = false;
28
- private final String videoQuality;
28
+ private String videoQuality;
29
+ private String videoCodec = "avc1";
29
30
  private boolean enablePhysicalDeviceSelection = false;
30
31
  private boolean barcodeScannerEnabled = false;
31
32
 
@@ -147,6 +148,18 @@ public class CameraSessionConfiguration {
147
148
  return videoQuality;
148
149
  }
149
150
 
151
+ public void setVideoQuality(String quality) {
152
+ this.videoQuality = quality != null ? quality : "high";
153
+ }
154
+
155
+ public String getVideoCodec() {
156
+ return videoCodec;
157
+ }
158
+
159
+ public void setVideoCodec(String codec) {
160
+ this.videoCodec = codec != null ? codec : "avc1";
161
+ }
162
+
150
163
  public boolean isPhysicalDeviceSelectionEnabled() {
151
164
  return enablePhysicalDeviceSelection;
152
165
  }
package/dist/docs.json CHANGED
@@ -495,9 +495,9 @@
495
495
  },
496
496
  {
497
497
  "name": "stopRecordVideo",
498
- "signature": "() => Promise<{ videoFilePath: string; }>",
498
+ "signature": "() => Promise<RecordingFinishedEvent>",
499
499
  "parameters": [],
500
- "returns": "Promise<{ videoFilePath: string; }>",
500
+ "returns": "Promise<RecordingFinishedEvent>",
501
501
  "tags": [
502
502
  {
503
503
  "name": "returns",
@@ -509,7 +509,9 @@
509
509
  }
510
510
  ],
511
511
  "docs": "Stops an ongoing video recording.",
512
- "complexTypes": [],
512
+ "complexTypes": [
513
+ "RecordingFinishedEvent"
514
+ ],
513
515
  "slug": "stoprecordvideo"
514
516
  },
515
517
  {
@@ -518,7 +520,7 @@
518
520
  "parameters": [
519
521
  {
520
522
  "name": "options",
521
- "docs": "- The options for video recording. Only iOS.",
523
+ "docs": "- The options for video recording.",
522
524
  "type": "CameraPreviewOptions"
523
525
  }
524
526
  ],
@@ -526,7 +528,7 @@
526
528
  "tags": [
527
529
  {
528
530
  "name": "param",
529
- "text": "options - The options for video recording. Only iOS."
531
+ "text": "options - The options for video recording."
530
532
  },
531
533
  {
532
534
  "name": "returns",
@@ -543,6 +545,176 @@
543
545
  ],
544
546
  "slug": "startrecordvideo"
545
547
  },
548
+ {
549
+ "name": "setVideoQuality",
550
+ "signature": "(options: { quality: VideoQuality; }) => Promise<void>",
551
+ "parameters": [
552
+ {
553
+ "name": "options",
554
+ "docs": "- The desired video quality.",
555
+ "type": "{ quality: VideoQuality; }"
556
+ }
557
+ ],
558
+ "returns": "Promise<void>",
559
+ "tags": [
560
+ {
561
+ "name": "param",
562
+ "text": "options - The desired video quality."
563
+ },
564
+ {
565
+ "name": "returns",
566
+ "text": "A promise that resolves when the quality is set."
567
+ },
568
+ {
569
+ "name": "since",
570
+ "text": "8.5.0"
571
+ },
572
+ {
573
+ "name": "platform",
574
+ "text": "android, ios"
575
+ }
576
+ ],
577
+ "docs": "Sets the video recording quality for the active camera session.",
578
+ "complexTypes": [
579
+ "VideoQuality"
580
+ ],
581
+ "slug": "setvideoquality"
582
+ },
583
+ {
584
+ "name": "getVideoQuality",
585
+ "signature": "() => Promise<{ quality: VideoQuality; }>",
586
+ "parameters": [],
587
+ "returns": "Promise<{ quality: VideoQuality; }>",
588
+ "tags": [
589
+ {
590
+ "name": "returns",
591
+ "text": "A promise that resolves with the current quality."
592
+ },
593
+ {
594
+ "name": "since",
595
+ "text": "8.5.0"
596
+ },
597
+ {
598
+ "name": "platform",
599
+ "text": "android, ios"
600
+ }
601
+ ],
602
+ "docs": "Gets the current video recording quality.",
603
+ "complexTypes": [
604
+ "VideoQuality"
605
+ ],
606
+ "slug": "getvideoquality"
607
+ },
608
+ {
609
+ "name": "getSupportedVideoQualities",
610
+ "signature": "() => Promise<{ qualities: VideoQuality[]; }>",
611
+ "parameters": [],
612
+ "returns": "Promise<{ qualities: VideoQuality[]; }>",
613
+ "tags": [
614
+ {
615
+ "name": "returns",
616
+ "text": "A promise that resolves with supported qualities."
617
+ },
618
+ {
619
+ "name": "since",
620
+ "text": "8.5.0"
621
+ },
622
+ {
623
+ "name": "platform",
624
+ "text": "android, ios"
625
+ }
626
+ ],
627
+ "docs": "Returns the video qualities supported by the active camera.",
628
+ "complexTypes": [
629
+ "VideoQuality"
630
+ ],
631
+ "slug": "getsupportedvideoqualities"
632
+ },
633
+ {
634
+ "name": "setVideoCodec",
635
+ "signature": "(options: { codec: VideoCodec; }) => Promise<void>",
636
+ "parameters": [
637
+ {
638
+ "name": "options",
639
+ "docs": "- The desired codec.",
640
+ "type": "{ codec: VideoCodec; }"
641
+ }
642
+ ],
643
+ "returns": "Promise<void>",
644
+ "tags": [
645
+ {
646
+ "name": "param",
647
+ "text": "options - The desired codec."
648
+ },
649
+ {
650
+ "name": "returns",
651
+ "text": "A promise that resolves when the codec is set."
652
+ },
653
+ {
654
+ "name": "since",
655
+ "text": "8.5.0"
656
+ },
657
+ {
658
+ "name": "platform",
659
+ "text": "android, ios"
660
+ }
661
+ ],
662
+ "docs": "Sets the video codec used when recording.",
663
+ "complexTypes": [
664
+ "VideoCodec"
665
+ ],
666
+ "slug": "setvideocodec"
667
+ },
668
+ {
669
+ "name": "getVideoCodec",
670
+ "signature": "() => Promise<{ codec: VideoCodec; }>",
671
+ "parameters": [],
672
+ "returns": "Promise<{ codec: VideoCodec; }>",
673
+ "tags": [
674
+ {
675
+ "name": "returns",
676
+ "text": "A promise that resolves with the current codec."
677
+ },
678
+ {
679
+ "name": "since",
680
+ "text": "8.5.0"
681
+ },
682
+ {
683
+ "name": "platform",
684
+ "text": "android, ios"
685
+ }
686
+ ],
687
+ "docs": "Gets the current video codec used for recording.",
688
+ "complexTypes": [
689
+ "VideoCodec"
690
+ ],
691
+ "slug": "getvideocodec"
692
+ },
693
+ {
694
+ "name": "getSupportedVideoCodecs",
695
+ "signature": "() => Promise<{ codecs: VideoCodec[]; }>",
696
+ "parameters": [],
697
+ "returns": "Promise<{ codecs: VideoCodec[]; }>",
698
+ "tags": [
699
+ {
700
+ "name": "returns",
701
+ "text": "A promise that resolves with supported codecs."
702
+ },
703
+ {
704
+ "name": "since",
705
+ "text": "8.5.0"
706
+ },
707
+ {
708
+ "name": "platform",
709
+ "text": "android, ios"
710
+ }
711
+ ],
712
+ "docs": "Returns the video codecs supported by the active camera.",
713
+ "complexTypes": [
714
+ "VideoCodec"
715
+ ],
716
+ "slug": "getsupportedvideocodecs"
717
+ },
546
718
  {
547
719
  "name": "isRunning",
548
720
  "signature": "() => Promise<{ isRunning: boolean; }>",
@@ -1011,6 +1183,39 @@
1011
1183
  ],
1012
1184
  "slug": "addlistenerbarcodescanerror-"
1013
1185
  },
1186
+ {
1187
+ "name": "addListener",
1188
+ "signature": "(eventName: 'recordingFinished', listenerFunc: (data: RecordingFinishedEvent) => void) => Promise<PluginListenerHandle>",
1189
+ "parameters": [
1190
+ {
1191
+ "name": "eventName",
1192
+ "docs": "",
1193
+ "type": "'recordingFinished'"
1194
+ },
1195
+ {
1196
+ "name": "listenerFunc",
1197
+ "docs": "",
1198
+ "type": "(data: RecordingFinishedEvent) => void"
1199
+ }
1200
+ ],
1201
+ "returns": "Promise<PluginListenerHandle>",
1202
+ "tags": [
1203
+ {
1204
+ "name": "since",
1205
+ "text": "8.4.7"
1206
+ },
1207
+ {
1208
+ "name": "platform",
1209
+ "text": "android, ios"
1210
+ }
1211
+ ],
1212
+ "docs": "Adds a listener fired when a video recording finishes natively, including automatic stops.",
1213
+ "complexTypes": [
1214
+ "PluginListenerHandle",
1215
+ "RecordingFinishedEvent"
1216
+ ],
1217
+ "slug": "addlistenerrecordingfinished-"
1218
+ },
1014
1219
  {
1015
1220
  "name": "deleteFile",
1016
1221
  "signature": "(options: { path: string; }) => Promise<{ success: boolean; }>",
@@ -1620,9 +1825,53 @@
1620
1825
  "name": "default"
1621
1826
  }
1622
1827
  ],
1623
- "docs": "Sets the quality of video for recording.\nOptions: 'low', 'medium', 'high'",
1828
+ "docs": "Sets the quality of video for recording.\nOptions: 'low', 'medium', 'high', '2160p', '1080p', '720p', '480p', '4:3'",
1829
+ "complexTypes": [
1830
+ "VideoQuality"
1831
+ ],
1832
+ "type": "VideoQuality"
1833
+ },
1834
+ {
1835
+ "name": "maxDuration",
1836
+ "tags": [
1837
+ {
1838
+ "text": "ios, android",
1839
+ "name": "platform"
1840
+ }
1841
+ ],
1842
+ "docs": "Maximum recording duration in seconds. Recording stops automatically when reached.",
1843
+ "complexTypes": [],
1844
+ "type": "number | undefined"
1845
+ },
1846
+ {
1847
+ "name": "maxFileSize",
1848
+ "tags": [
1849
+ {
1850
+ "text": "ios, android",
1851
+ "name": "platform"
1852
+ }
1853
+ ],
1854
+ "docs": "Maximum recording file size in bytes. Recording stops automatically when reached.",
1624
1855
  "complexTypes": [],
1625
- "type": "'low' | 'medium' | 'high' | undefined"
1856
+ "type": "number | undefined"
1857
+ },
1858
+ {
1859
+ "name": "videoCodec",
1860
+ "tags": [
1861
+ {
1862
+ "text": "ios, android",
1863
+ "name": "platform"
1864
+ },
1865
+ {
1866
+ "text": "\"avc1\"",
1867
+ "name": "default"
1868
+ }
1869
+ ],
1870
+ "docs": "Preferred video codec for recording.",
1871
+ "complexTypes": [
1872
+ "VideoCodec"
1873
+ ],
1874
+ "type": "VideoCodec"
1626
1875
  },
1627
1876
  {
1628
1877
  "name": "barcodeScanner",
@@ -1983,6 +2232,31 @@
1983
2232
  }
1984
2233
  ]
1985
2234
  },
2235
+ {
2236
+ "name": "RecordingFinishedEvent",
2237
+ "slug": "recordingfinishedevent",
2238
+ "docs": "",
2239
+ "tags": [],
2240
+ "methods": [],
2241
+ "properties": [
2242
+ {
2243
+ "name": "videoFilePath",
2244
+ "tags": [],
2245
+ "docs": "The path to the recorded video file.",
2246
+ "complexTypes": [],
2247
+ "type": "string"
2248
+ },
2249
+ {
2250
+ "name": "reason",
2251
+ "tags": [],
2252
+ "docs": "Why the recording stopped.",
2253
+ "complexTypes": [
2254
+ "RecordingFinishedReason"
2255
+ ],
2256
+ "type": "RecordingFinishedReason"
2257
+ }
2258
+ ]
2259
+ },
1986
2260
  {
1987
2261
  "name": "CameraDevice",
1988
2262
  "slug": "cameradevice",
@@ -2373,6 +2647,72 @@
2373
2647
  }
2374
2648
  ]
2375
2649
  },
2650
+ {
2651
+ "name": "VideoQuality",
2652
+ "slug": "videoquality",
2653
+ "docs": "",
2654
+ "types": [
2655
+ {
2656
+ "text": "'low'",
2657
+ "complexTypes": []
2658
+ },
2659
+ {
2660
+ "text": "'medium'",
2661
+ "complexTypes": []
2662
+ },
2663
+ {
2664
+ "text": "'high'",
2665
+ "complexTypes": []
2666
+ },
2667
+ {
2668
+ "text": "'2160p'",
2669
+ "complexTypes": []
2670
+ },
2671
+ {
2672
+ "text": "'1080p'",
2673
+ "complexTypes": []
2674
+ },
2675
+ {
2676
+ "text": "'720p'",
2677
+ "complexTypes": []
2678
+ },
2679
+ {
2680
+ "text": "'480p'",
2681
+ "complexTypes": []
2682
+ },
2683
+ {
2684
+ "text": "'4:3'",
2685
+ "complexTypes": []
2686
+ }
2687
+ ]
2688
+ },
2689
+ {
2690
+ "name": "VideoCodec",
2691
+ "slug": "videocodec",
2692
+ "docs": "Video codec identifiers used when recording.\n- `avc1`: H.264\n- `hvc1`: HEVC / H.265",
2693
+ "types": [
2694
+ {
2695
+ "text": "'avc1'",
2696
+ "complexTypes": []
2697
+ },
2698
+ {
2699
+ "text": "'hvc1'",
2700
+ "complexTypes": []
2701
+ },
2702
+ {
2703
+ "text": "'jpeg'",
2704
+ "complexTypes": []
2705
+ },
2706
+ {
2707
+ "text": "'apcn'",
2708
+ "complexTypes": []
2709
+ },
2710
+ {
2711
+ "text": "'ap4h'",
2712
+ "complexTypes": []
2713
+ }
2714
+ ]
2715
+ },
2376
2716
  {
2377
2717
  "name": "BarcodeScannerFormat",
2378
2718
  "slug": "barcodescannerformat",
@@ -2508,6 +2848,25 @@
2508
2848
  }
2509
2849
  ]
2510
2850
  },
2851
+ {
2852
+ "name": "RecordingFinishedReason",
2853
+ "slug": "recordingfinishedreason",
2854
+ "docs": "",
2855
+ "types": [
2856
+ {
2857
+ "text": "'manual'",
2858
+ "complexTypes": []
2859
+ },
2860
+ {
2861
+ "text": "'maxDuration'",
2862
+ "complexTypes": []
2863
+ },
2864
+ {
2865
+ "text": "'maxFileSize'",
2866
+ "complexTypes": []
2867
+ }
2868
+ ]
2869
+ },
2511
2870
  {
2512
2871
  "name": "FlashMode",
2513
2872
  "slug": "flashmode",
@@ -107,6 +107,24 @@ export interface LensInfo {
107
107
  /** The current digital zoom factor applied on top of the base zoom. */
108
108
  digitalZoom: number;
109
109
  }
110
+ export type VideoQuality = 'low' | 'medium' | 'high' | '2160p' | '1080p' | '720p' | '480p' | '4:3';
111
+ /**
112
+ * Video codec identifiers used when recording.
113
+ * - `avc1`: H.264
114
+ * - `hvc1`: HEVC / H.265
115
+ */
116
+ export type VideoCodec = 'avc1' | 'hvc1' | 'jpeg' | 'apcn' | 'ap4h';
117
+ export type RecordingFinishedReason = 'manual' | 'maxDuration' | 'maxFileSize';
118
+ export interface RecordingFinishedEvent {
119
+ /**
120
+ * The path to the recorded video file.
121
+ */
122
+ videoFilePath: string;
123
+ /**
124
+ * Why the recording stopped.
125
+ */
126
+ reason: RecordingFinishedReason;
127
+ }
110
128
  /**
111
129
  * Defines the configuration options for starting the camera preview.
112
130
  */
@@ -269,13 +287,29 @@ export interface CameraPreviewOptions {
269
287
  force?: boolean;
270
288
  /**
271
289
  * Sets the quality of video for recording.
272
- * Options: 'low', 'medium', 'high'
290
+ * Options: 'low', 'medium', 'high', '2160p', '1080p', '720p', '480p', '4:3'
273
291
  * @note On Android requires 'enableVideoMode' to be true
274
292
  * @note Will affect the entire preview stream for iOS
275
293
  * @platform ios, android
276
294
  * @default "high"
277
295
  */
278
- videoQuality?: 'low' | 'medium' | 'high';
296
+ videoQuality?: VideoQuality;
297
+ /**
298
+ * Maximum recording duration in seconds. Recording stops automatically when reached.
299
+ * @platform ios, android
300
+ */
301
+ maxDuration?: number;
302
+ /**
303
+ * Maximum recording file size in bytes. Recording stops automatically when reached.
304
+ * @platform ios, android
305
+ */
306
+ maxFileSize?: number;
307
+ /**
308
+ * Preferred video codec for recording.
309
+ * @platform ios, android
310
+ * @default "avc1"
311
+ */
312
+ videoCodec?: VideoCodec;
279
313
  /**
280
314
  * Starts barcode scanning together with the camera preview.
281
315
  * Set to `true` or pass options to scan all supported formats.
@@ -617,20 +651,80 @@ export interface CameraPreviewPlugin {
617
651
  /**
618
652
  * Stops an ongoing video recording.
619
653
  *
620
- * @returns {Promise<{ videoFilePath: string }>} A promise that resolves with the path to the recorded video file.
654
+ * @returns {Promise<RecordingFinishedEvent>} A promise that resolves with the path to the recorded video file.
621
655
  * @since 0.0.1
622
656
  */
623
- stopRecordVideo(): Promise<{
624
- videoFilePath: string;
625
- }>;
657
+ stopRecordVideo(): Promise<RecordingFinishedEvent>;
626
658
  /**
627
659
  * Starts recording a video.
628
660
  *
629
- * @param {CameraPreviewOptions} options - The options for video recording. Only iOS.
661
+ * @param {CameraPreviewOptions} options - The options for video recording.
630
662
  * @returns {Promise<void>} A promise that resolves when video recording starts.
631
663
  * @since 0.0.1
632
664
  */
633
665
  startRecordVideo(options: CameraPreviewOptions): Promise<void>;
666
+ /**
667
+ * Sets the video recording quality for the active camera session.
668
+ *
669
+ * @param {{ quality: VideoQuality }} options - The desired video quality.
670
+ * @returns {Promise<void>} A promise that resolves when the quality is set.
671
+ * @since 8.5.0
672
+ * @platform android, ios
673
+ */
674
+ setVideoQuality(options: {
675
+ quality: VideoQuality;
676
+ }): Promise<void>;
677
+ /**
678
+ * Gets the current video recording quality.
679
+ *
680
+ * @returns {Promise<{ quality: VideoQuality }>} A promise that resolves with the current quality.
681
+ * @since 8.5.0
682
+ * @platform android, ios
683
+ */
684
+ getVideoQuality(): Promise<{
685
+ quality: VideoQuality;
686
+ }>;
687
+ /**
688
+ * Returns the video qualities supported by the active camera.
689
+ *
690
+ * @returns {Promise<{ qualities: VideoQuality[] }>} A promise that resolves with supported qualities.
691
+ * @since 8.5.0
692
+ * @platform android, ios
693
+ */
694
+ getSupportedVideoQualities(): Promise<{
695
+ qualities: VideoQuality[];
696
+ }>;
697
+ /**
698
+ * Sets the video codec used when recording.
699
+ *
700
+ * @param {{ codec: VideoCodec }} options - The desired codec.
701
+ * @returns {Promise<void>} A promise that resolves when the codec is set.
702
+ * @since 8.5.0
703
+ * @platform android, ios
704
+ */
705
+ setVideoCodec(options: {
706
+ codec: VideoCodec;
707
+ }): Promise<void>;
708
+ /**
709
+ * Gets the current video codec used for recording.
710
+ *
711
+ * @returns {Promise<{ codec: VideoCodec }>} A promise that resolves with the current codec.
712
+ * @since 8.5.0
713
+ * @platform android, ios
714
+ */
715
+ getVideoCodec(): Promise<{
716
+ codec: VideoCodec;
717
+ }>;
718
+ /**
719
+ * Returns the video codecs supported by the active camera.
720
+ *
721
+ * @returns {Promise<{ codecs: VideoCodec[] }>} A promise that resolves with supported codecs.
722
+ * @since 8.5.0
723
+ * @platform android, ios
724
+ */
725
+ getSupportedVideoCodecs(): Promise<{
726
+ codecs: VideoCodec[];
727
+ }>;
634
728
  /**
635
729
  * Checks if the camera preview is currently running.
636
730
  *
@@ -812,6 +906,13 @@ export interface CameraPreviewPlugin {
812
906
  * @platform android, web
813
907
  */
814
908
  addListener(eventName: 'barcodeScanError', listenerFunc: (data: BarcodeScanErrorEvent) => void): Promise<PluginListenerHandle>;
909
+ /**
910
+ * Adds a listener fired when a video recording finishes natively, including automatic stops.
911
+ *
912
+ * @since 8.4.7
913
+ * @platform android, ios
914
+ */
915
+ addListener(eventName: 'recordingFinished', listenerFunc: (data: RecordingFinishedEvent) => void): Promise<PluginListenerHandle>;
815
916
  /**
816
917
  * Deletes a file at the given absolute path on the device.
817
918
  * Use this to quickly clean up temporary images created with `storeToFile`.