@capacitor-community/camera-preview 5.0.0-0 → 5.0.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.
- package/README.md +19 -13
- package/android/.gradle/8.0.2/checksums/checksums.lock +0 -0
- package/android/.gradle/8.0.2/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/8.0.2/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.0.2/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/8.0.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.0.2/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.0.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.0.2/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/build.gradle +3 -2
- package/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +3 -3
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraActivity.java +5 -7
- package/dist/esm/definitions.d.ts +2 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +3 -3
- package/dist/esm/web.js +14 -10
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +155 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +158 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/CameraController.swift +1 -1
- package/ios/Plugin/Plugin.swift +5 -5
- package/ios/Podfile +7 -4
- package/ios/Podfile.lock +9 -10
- package/ios/Pods/CapacitorCordova/LICENSE +23 -0
- package/ios/Pods/CapacitorCordova/README.md +39 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.h +21 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/AppDelegate.h +8 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/AppDelegate.m +5 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDV.h +28 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVAvailability.h +109 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegate.h +51 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegateImpl.h +39 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegateImpl.m +154 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVConfigParser.h +31 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVConfigParser.m +81 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVInvokedUrlCommand.h +52 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVInvokedUrlCommand.m +116 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPlugin.h +81 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPlugin.m +154 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginManager.h +25 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginManager.m +77 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginResult.h +82 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginResult.m +216 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVScreenOrientationDelegate.h +33 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVUIWebViewDelegate.h +41 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVUIWebViewDelegate.m +399 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVURLProtocol.h +27 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVURLProtocol.m +74 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVUserAgentUtil.h +27 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVUserAgentUtil.m +156 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVViewController.h +30 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVViewController.m +34 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/NSDictionary+CordovaPreferences.h +35 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/NSDictionary+CordovaPreferences.m +63 -0
- package/ios/Pods/Local Podspecs/Capacitor.podspec.json +34 -0
- package/ios/Pods/Local Podspecs/CapacitorCordova.podspec.json +26 -0
- package/ios/Pods/Manifest.lock +22 -0
- package/ios/Pods/Pods.xcodeproj/project.pbxproj +1374 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/julionic.xcuserdatad/xcschemes/Capacitor.xcscheme +58 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/julionic.xcuserdatad/xcschemes/CapacitorCordova.xcscheme +58 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/julionic.xcuserdatad/xcschemes/Pods-Plugin.xcscheme +58 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/julionic.xcuserdatad/xcschemes/Pods-PluginTests.xcscheme +58 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/julionic.xcuserdatad/xcschemes/xcschememanagement.plist +31 -0
- package/ios/Pods/Target Support Files/Capacitor/Capacitor-Info.plist +26 -0
- package/ios/Pods/Target Support Files/Capacitor/Capacitor-dummy.m +5 -0
- package/ios/Pods/Target Support Files/Capacitor/Capacitor-prefix.pch +12 -0
- package/ios/Pods/Target Support Files/Capacitor/Capacitor.debug.xcconfig +15 -0
- package/ios/Pods/Target Support Files/Capacitor/Capacitor.modulemap +8 -0
- package/ios/Pods/Target Support Files/Capacitor/Capacitor.release.xcconfig +15 -0
- package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-Info.plist +26 -0
- package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-dummy.m +5 -0
- package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-prefix.pch +12 -0
- package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-umbrella.h +32 -0
- package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova.debug.xcconfig +12 -0
- package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova.modulemap +6 -0
- package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova.release.xcconfig +12 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-Info.plist +26 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-acknowledgements.markdown +53 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-acknowledgements.plist +91 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-dummy.m +5 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-umbrella.h +16 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin.debug.xcconfig +14 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin.modulemap +6 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin.release.xcconfig +14 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-Info.plist +26 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-acknowledgements.markdown +53 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-acknowledgements.plist +91 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-dummy.m +5 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-frameworks.sh +188 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-umbrella.h +16 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.debug.xcconfig +15 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.modulemap +6 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.release.xcconfig +15 -0
- package/package.json +17 -7
package/README.md
CHANGED
|
@@ -2,14 +2,19 @@
|
|
|
2
2
|
<h3 align="center">Capacitor Camera Preview</h3>
|
|
3
3
|
<p align="center"><strong><code>@capacitor-community/camera-preview</code></strong></p>
|
|
4
4
|
<br>
|
|
5
|
-
<p align="center"><strong>CAPACITOR
|
|
5
|
+
<p align="center"><strong>CAPACITOR 5</strong></p><br>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
8
|
Capacitor plugin that allows camera interaction from Javascript and HTML<br>(based on cordova-plugin-camera-preview).
|
|
9
9
|
</p>
|
|
10
10
|
<br>
|
|
11
|
-
Version
|
|
12
|
-
|
|
11
|
+
Version 5 of this plugin requires Capacitor 5.
|
|
12
|
+
|
|
13
|
+
If you are using Capacitor 4, use [version 4](https://github.com/capacitor-community/camera-preview/releases/tag/v4.0.0)
|
|
14
|
+
|
|
15
|
+
If you are using Capacitor 3, use [version 3](https://github.com/capacitor-community/camera-preview/releases/tag/v3.1.2)
|
|
16
|
+
|
|
17
|
+
If you are using Capacitor 2, use [version 1](https://github.com/capacitor-community/camera-preview/releases/tag/v1.2.1)
|
|
13
18
|
|
|
14
19
|
**PR's are greatly appreciated.**
|
|
15
20
|
|
|
@@ -53,20 +58,22 @@ Open `android/app/src/main/AndroidManifest.xml` and above the closing `</manifes
|
|
|
53
58
|
```
|
|
54
59
|
For more help consult the [Capacitor docs](https://capacitorjs.com/docs/android/configuration#configuring-androidmanifestxml).
|
|
55
60
|
|
|
61
|
+
### Variables
|
|
62
|
+
|
|
63
|
+
This plugin will use the following project variables (defined in your app's `variables.gradle` file):
|
|
64
|
+
|
|
65
|
+
- `androidxExifInterfaceVersion`: version of `androidx.exifinterface:exifinterface` (default: `1.3.6`)
|
|
66
|
+
|
|
56
67
|
## Extra iOS installation steps
|
|
57
68
|
You will need to add two permissions to `Info.plist`. Follow the [Capacitor docs](https://capacitorjs.com/docs/ios/configuration#configuring-infoplist) and add permissions with the raw keys `NSCameraUsageDescription` and `NSMicrophoneUsageDescription`. `NSMicrophoneUsageDescription` is only required, if audio will be used. Otherwise set the `disableAudio` option to `true`, which also disables the microphone permission request.
|
|
58
69
|
|
|
59
70
|
## Extra Web installation steps
|
|
60
|
-
Add `import '@capacitor-community/camera-preview'` to you entry script in ionic on `app.module.ts`, so capacitor can register the web platform from the plugin
|
|
61
|
-
|
|
62
|
-
then in html add
|
|
63
71
|
|
|
64
|
-
|
|
72
|
+
Add `import { CameraPreview } from '@capacitor-community/camera-preview';` in the file where you want to use the plugin.
|
|
65
73
|
|
|
66
|
-
|
|
67
|
-
ngOnInit() { const { CameraPreview } = Plugins; CameraPreview.start({ parent: "cameraPreview"}); }
|
|
74
|
+
then in html add `<div id="cameraPreview"></div>`
|
|
68
75
|
|
|
69
|
-
|
|
76
|
+
and `CameraPreview.start({ parent: "cameraPreview"});` will work.
|
|
70
77
|
|
|
71
78
|
|
|
72
79
|
# Methods
|
|
@@ -257,7 +264,7 @@ const CameraPreviewFlashMode: CameraPreviewFlashMode = 'torch';
|
|
|
257
264
|
CameraPreview.setFlashMode(cameraPreviewFlashMode);
|
|
258
265
|
```
|
|
259
266
|
|
|
260
|
-
### startRecordVideo(options) ---- ANDROID only
|
|
267
|
+
### startRecordVideo(options) ---- ANDROID and iOS only
|
|
261
268
|
|
|
262
269
|
<info>Start capturing video</info><br/>
|
|
263
270
|
|
|
@@ -271,13 +278,12 @@ const cameraPreviewOptions: CameraPreviewOptions = {
|
|
|
271
278
|
CameraPreview.startRecordVideo(cameraPreviewOptions);
|
|
272
279
|
```
|
|
273
280
|
|
|
274
|
-
### stopRecordVideo() ---- ANDROID only
|
|
281
|
+
### stopRecordVideo() ---- ANDROID and iOS only
|
|
275
282
|
|
|
276
283
|
<info>Finish capturing a video. The captured video will be returned as a file path and the video format is .mp4</info><br/>
|
|
277
284
|
|
|
278
285
|
```javascript
|
|
279
286
|
const resultRecordVideo = await CameraPreview.stopRecordVideo();
|
|
280
|
-
this.stopCamera();
|
|
281
287
|
```
|
|
282
288
|
|
|
283
289
|
### setOpacity(options: CameraOpacityOptions): Promise<{}>; ---- ANDROID only
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/android/build.gradle
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
ext {
|
|
2
2
|
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
3
|
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
|
|
4
|
+
androidxExifInterfaceVersion = project.hasProperty('androidxExifInterfaceVersion') ? rootProject.ext.androidxExifInterfaceVersion : '1.3.6'
|
|
4
5
|
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
|
|
5
6
|
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
|
|
6
7
|
}
|
|
@@ -25,7 +26,7 @@ android {
|
|
|
25
26
|
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
|
|
26
27
|
versionCode 1
|
|
27
28
|
versionName "1.0"
|
|
28
|
-
testInstrumentationRunner "
|
|
29
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
29
30
|
}
|
|
30
31
|
buildTypes {
|
|
31
32
|
release {
|
|
@@ -48,7 +49,7 @@ dependencies {
|
|
|
48
49
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
49
50
|
implementation project(':capacitor-android')
|
|
50
51
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
51
|
-
implementation
|
|
52
|
+
implementation "androidx.exifinterface:exifinterface:$androidxExifInterfaceVersion"
|
|
52
53
|
testImplementation "junit:junit:$junitVersion"
|
|
53
54
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
54
55
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
@@ -3,8 +3,8 @@ package com.getcapacitor.android;
|
|
|
3
3
|
import static org.junit.Assert.*;
|
|
4
4
|
|
|
5
5
|
import android.content.Context;
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
|
7
|
+
import androidx.test.platform.app.InstrumentationRegistry;
|
|
8
8
|
import org.junit.Test;
|
|
9
9
|
import org.junit.runner.RunWith;
|
|
10
10
|
|
|
@@ -19,7 +19,7 @@ public class ExampleInstrumentedTest {
|
|
|
19
19
|
@Test
|
|
20
20
|
public void useAppContext() throws Exception {
|
|
21
21
|
// Context of the app under test.
|
|
22
|
-
Context appContext = InstrumentationRegistry.getTargetContext();
|
|
22
|
+
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
|
23
23
|
|
|
24
24
|
assertEquals("com.getcapacitor.android", appContext.getPackageName());
|
|
25
25
|
}
|
|
@@ -396,15 +396,16 @@ public class CameraActivity extends Fragment {
|
|
|
396
396
|
super.onConfigurationChanged(newConfig);
|
|
397
397
|
|
|
398
398
|
final FrameLayout frameContainerLayout = (FrameLayout) view.findViewById(
|
|
399
|
-
|
|
399
|
+
getResources().getIdentifier("frame_container", "id", appResourcesPackage)
|
|
400
400
|
);
|
|
401
401
|
|
|
402
|
-
final int previousOrientation = frameContainerLayout.getHeight() > frameContainerLayout.getWidth()
|
|
402
|
+
final int previousOrientation = frameContainerLayout.getHeight() > frameContainerLayout.getWidth()
|
|
403
|
+
? Configuration.ORIENTATION_PORTRAIT
|
|
404
|
+
: Configuration.ORIENTATION_LANDSCAPE;
|
|
403
405
|
// Checks if the orientation of the screen has changed
|
|
404
406
|
if (newConfig.orientation != previousOrientation) {
|
|
405
|
-
|
|
406
407
|
final RelativeLayout frameCamContainerLayout = (RelativeLayout) view.findViewById(
|
|
407
|
-
|
|
408
|
+
getResources().getIdentifier("frame_camera_cont", "id", appResourcesPackage)
|
|
408
409
|
);
|
|
409
410
|
|
|
410
411
|
frameContainerLayout.getLayoutParams().width = frameCamContainerLayout.getHeight();
|
|
@@ -419,12 +420,9 @@ public class CameraActivity extends Fragment {
|
|
|
419
420
|
frameCamContainerLayout.forceLayout();
|
|
420
421
|
|
|
421
422
|
mPreview.setCameraDisplayOrientation();
|
|
422
|
-
|
|
423
423
|
}
|
|
424
|
-
|
|
425
424
|
}
|
|
426
425
|
|
|
427
|
-
|
|
428
426
|
public Camera getCamera() {
|
|
429
427
|
return mCamera;
|
|
430
428
|
}
|
|
@@ -56,7 +56,9 @@ export interface CameraOpacityOptions {
|
|
|
56
56
|
}
|
|
57
57
|
export interface CameraPreviewPlugin {
|
|
58
58
|
start(options: CameraPreviewOptions): Promise<{}>;
|
|
59
|
+
startRecordVideo(options: CameraPreviewOptions): Promise<{}>;
|
|
59
60
|
stop(): Promise<{}>;
|
|
61
|
+
stopRecordVideo(): Promise<{}>;
|
|
60
62
|
capture(options: CameraPreviewPictureOptions): Promise<{
|
|
61
63
|
value: string;
|
|
62
64
|
}>;
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,aAAa,GAAG,cAAc,CAAsB,eAAe,EAAE;IACzE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;CACjE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { WebPlugin } from '@capacitor/core';
|
|
2
|
-
import { CameraPreviewOptions, CameraPreviewPictureOptions, CameraPreviewPlugin, CameraPreviewFlashMode, CameraSampleOptions, CameraOpacityOptions } from './definitions';
|
|
2
|
+
import type { CameraPreviewOptions, CameraPreviewPictureOptions, CameraPreviewPlugin, CameraPreviewFlashMode, CameraSampleOptions, CameraOpacityOptions } from './definitions';
|
|
3
3
|
export declare class CameraPreviewWeb extends WebPlugin implements CameraPreviewPlugin {
|
|
4
4
|
/**
|
|
5
5
|
* track which camera is used based on start options
|
|
@@ -8,6 +8,8 @@ export declare class CameraPreviewWeb extends WebPlugin implements CameraPreview
|
|
|
8
8
|
private isBackCamera;
|
|
9
9
|
constructor();
|
|
10
10
|
start(options: CameraPreviewOptions): Promise<{}>;
|
|
11
|
+
startRecordVideo(): Promise<{}>;
|
|
12
|
+
stopRecordVideo(): Promise<{}>;
|
|
11
13
|
stop(): Promise<any>;
|
|
12
14
|
capture(options: CameraPreviewPictureOptions): Promise<any>;
|
|
13
15
|
captureSample(_options: CameraSampleOptions): Promise<any>;
|
|
@@ -20,5 +22,3 @@ export declare class CameraPreviewWeb extends WebPlugin implements CameraPreview
|
|
|
20
22
|
flip(): Promise<void>;
|
|
21
23
|
setOpacity(_options: CameraOpacityOptions): Promise<any>;
|
|
22
24
|
}
|
|
23
|
-
declare const CameraPreview: CameraPreviewWeb;
|
|
24
|
-
export { CameraPreview };
|
package/dist/esm/web.js
CHANGED
|
@@ -11,7 +11,7 @@ export class CameraPreviewWeb extends WebPlugin {
|
|
|
11
11
|
await navigator.mediaDevices
|
|
12
12
|
.getUserMedia({
|
|
13
13
|
audio: !options.disableAudio,
|
|
14
|
-
video: true
|
|
14
|
+
video: true,
|
|
15
15
|
})
|
|
16
16
|
.then((stream) => {
|
|
17
17
|
// Stop any existing stream so we can request media with different constraints based on user input
|
|
@@ -45,8 +45,8 @@ export class CameraPreviewWeb extends WebPlugin {
|
|
|
45
45
|
const constraints = {
|
|
46
46
|
video: {
|
|
47
47
|
width: { ideal: options.width },
|
|
48
|
-
height: { ideal: options.height }
|
|
49
|
-
}
|
|
48
|
+
height: { ideal: options.height },
|
|
49
|
+
},
|
|
50
50
|
};
|
|
51
51
|
if (options.position === 'rear') {
|
|
52
52
|
constraints.video.facingMode = 'environment';
|
|
@@ -70,14 +70,20 @@ export class CameraPreviewWeb extends WebPlugin {
|
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
+
async startRecordVideo() {
|
|
74
|
+
throw this.unimplemented('Not implemented on web.');
|
|
75
|
+
}
|
|
76
|
+
async stopRecordVideo() {
|
|
77
|
+
throw this.unimplemented('Not implemented on web.');
|
|
78
|
+
}
|
|
73
79
|
async stop() {
|
|
74
80
|
const video = document.getElementById('video');
|
|
75
81
|
if (video) {
|
|
76
82
|
video.pause();
|
|
77
83
|
const st = video.srcObject;
|
|
78
84
|
const tracks = st.getTracks();
|
|
79
|
-
for (
|
|
80
|
-
|
|
85
|
+
for (let i = 0; i < tracks.length; i++) {
|
|
86
|
+
const track = tracks[i];
|
|
81
87
|
track.stop();
|
|
82
88
|
}
|
|
83
89
|
video.remove();
|
|
@@ -99,7 +105,9 @@ export class CameraPreviewWeb extends WebPlugin {
|
|
|
99
105
|
context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
|
|
100
106
|
let base64EncodedImage;
|
|
101
107
|
if (options.quality != undefined) {
|
|
102
|
-
base64EncodedImage = canvas
|
|
108
|
+
base64EncodedImage = canvas
|
|
109
|
+
.toDataURL('image/jpeg', options.quality / 100.0)
|
|
110
|
+
.replace('data:image/jpeg;base64,', '');
|
|
103
111
|
}
|
|
104
112
|
else {
|
|
105
113
|
base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');
|
|
@@ -128,8 +136,4 @@ export class CameraPreviewWeb extends WebPlugin {
|
|
|
128
136
|
}
|
|
129
137
|
}
|
|
130
138
|
}
|
|
131
|
-
const CameraPreview = new CameraPreviewWeb();
|
|
132
|
-
export { CameraPreview };
|
|
133
|
-
import { registerWebPlugin } from '@capacitor/core';
|
|
134
|
-
registerWebPlugin(CameraPreview);
|
|
135
139
|
//# sourceMappingURL=web.js.map
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAA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U,CAAC,QAA8B;QAC7C,MAAM,KAAK,GAAqB,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACjE,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;YACpC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;SACpE;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@capacitor/core');
|
|
6
|
+
|
|
7
|
+
const CameraPreview = core.registerPlugin('CameraPreview', {
|
|
8
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CameraPreviewWeb()),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
class CameraPreviewWeb extends core.WebPlugin {
|
|
12
|
+
constructor() {
|
|
13
|
+
super({
|
|
14
|
+
name: 'CameraPreview',
|
|
15
|
+
platforms: ['web'],
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async start(options) {
|
|
19
|
+
return new Promise(async (resolve, reject) => {
|
|
20
|
+
await navigator.mediaDevices
|
|
21
|
+
.getUserMedia({
|
|
22
|
+
audio: !options.disableAudio,
|
|
23
|
+
video: true,
|
|
24
|
+
})
|
|
25
|
+
.then((stream) => {
|
|
26
|
+
// Stop any existing stream so we can request media with different constraints based on user input
|
|
27
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
28
|
+
})
|
|
29
|
+
.catch((error) => {
|
|
30
|
+
reject(error);
|
|
31
|
+
});
|
|
32
|
+
const video = document.getElementById('video');
|
|
33
|
+
const parent = document.getElementById(options.parent);
|
|
34
|
+
if (!video) {
|
|
35
|
+
const videoElement = document.createElement('video');
|
|
36
|
+
videoElement.id = 'video';
|
|
37
|
+
videoElement.setAttribute('class', options.className || '');
|
|
38
|
+
// Don't flip video feed if camera is rear facing
|
|
39
|
+
if (options.position !== 'rear') {
|
|
40
|
+
videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');
|
|
41
|
+
}
|
|
42
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
43
|
+
const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');
|
|
44
|
+
// Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful
|
|
45
|
+
// Without these attributes videoElement.play() will throw a NotAllowedError
|
|
46
|
+
// https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari
|
|
47
|
+
if (isSafari) {
|
|
48
|
+
videoElement.setAttribute('autoplay', 'true');
|
|
49
|
+
videoElement.setAttribute('muted', 'true');
|
|
50
|
+
videoElement.setAttribute('playsinline', 'true');
|
|
51
|
+
}
|
|
52
|
+
parent.appendChild(videoElement);
|
|
53
|
+
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
|
54
|
+
const constraints = {
|
|
55
|
+
video: {
|
|
56
|
+
width: { ideal: options.width },
|
|
57
|
+
height: { ideal: options.height },
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
if (options.position === 'rear') {
|
|
61
|
+
constraints.video.facingMode = 'environment';
|
|
62
|
+
this.isBackCamera = true;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.isBackCamera = false;
|
|
66
|
+
}
|
|
67
|
+
navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
|
|
68
|
+
//video.src = window.URL.createObjectURL(stream);
|
|
69
|
+
videoElement.srcObject = stream;
|
|
70
|
+
videoElement.play();
|
|
71
|
+
resolve({});
|
|
72
|
+
}, (err) => {
|
|
73
|
+
reject(err);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
reject({ message: 'camera already started' });
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async startRecordVideo() {
|
|
83
|
+
throw this.unimplemented('Not implemented on web.');
|
|
84
|
+
}
|
|
85
|
+
async stopRecordVideo() {
|
|
86
|
+
throw this.unimplemented('Not implemented on web.');
|
|
87
|
+
}
|
|
88
|
+
async stop() {
|
|
89
|
+
const video = document.getElementById('video');
|
|
90
|
+
if (video) {
|
|
91
|
+
video.pause();
|
|
92
|
+
const st = video.srcObject;
|
|
93
|
+
const tracks = st.getTracks();
|
|
94
|
+
for (let i = 0; i < tracks.length; i++) {
|
|
95
|
+
const track = tracks[i];
|
|
96
|
+
track.stop();
|
|
97
|
+
}
|
|
98
|
+
video.remove();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async capture(options) {
|
|
102
|
+
return new Promise((resolve, _) => {
|
|
103
|
+
const video = document.getElementById('video');
|
|
104
|
+
const canvas = document.createElement('canvas');
|
|
105
|
+
// video.width = video.offsetWidth;
|
|
106
|
+
const context = canvas.getContext('2d');
|
|
107
|
+
canvas.width = video.videoWidth;
|
|
108
|
+
canvas.height = video.videoHeight;
|
|
109
|
+
// flip horizontally back camera isn't used
|
|
110
|
+
if (!this.isBackCamera) {
|
|
111
|
+
context.translate(video.videoWidth, 0);
|
|
112
|
+
context.scale(-1, 1);
|
|
113
|
+
}
|
|
114
|
+
context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
|
|
115
|
+
let base64EncodedImage;
|
|
116
|
+
if (options.quality != undefined) {
|
|
117
|
+
base64EncodedImage = canvas
|
|
118
|
+
.toDataURL('image/jpeg', options.quality / 100.0)
|
|
119
|
+
.replace('data:image/jpeg;base64,', '');
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');
|
|
123
|
+
}
|
|
124
|
+
resolve({
|
|
125
|
+
value: base64EncodedImage,
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
async captureSample(_options) {
|
|
130
|
+
return this.capture(_options);
|
|
131
|
+
}
|
|
132
|
+
async getSupportedFlashModes() {
|
|
133
|
+
throw new Error('getSupportedFlashModes not supported under the web platform');
|
|
134
|
+
}
|
|
135
|
+
async setFlashMode(_options) {
|
|
136
|
+
throw new Error('setFlashMode not supported under the web platform');
|
|
137
|
+
}
|
|
138
|
+
async flip() {
|
|
139
|
+
throw new Error('flip not supported under the web platform');
|
|
140
|
+
}
|
|
141
|
+
async setOpacity(_options) {
|
|
142
|
+
const video = document.getElementById('video');
|
|
143
|
+
if (!!video && !!_options['opacity']) {
|
|
144
|
+
video.style.setProperty('opacity', _options['opacity'].toString());
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
150
|
+
__proto__: null,
|
|
151
|
+
CameraPreviewWeb: CameraPreviewWeb
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
exports.CameraPreview = CameraPreview;
|
|
155
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraPreview = registerPlugin('CameraPreview', {\n web: () => import('./web').then((m) => new m.CameraPreviewWeb()),\n});\nexport * from './definitions';\nexport { CameraPreview };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraPreviewWeb extends WebPlugin {\n constructor() {\n super({\n name: 'CameraPreview',\n platforms: ['web'],\n });\n }\n async start(options) {\n return new Promise(async (resolve, reject) => {\n await navigator.mediaDevices\n .getUserMedia({\n audio: !options.disableAudio,\n video: true,\n })\n .then((stream) => {\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n })\n .catch((error) => {\n reject(error);\n });\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent);\n if (!video) {\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n parent.appendChild(videoElement);\n if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {\n const constraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n if (options.position === 'rear') {\n constraints.video.facingMode = 'environment';\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {\n //video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n resolve({});\n }, (err) => {\n reject(err);\n });\n }\n }\n else {\n reject({ message: 'camera already started' });\n }\n });\n }\n async startRecordVideo() {\n throw this.unimplemented('Not implemented on web.');\n }\n async stopRecordVideo() {\n throw this.unimplemented('Not implemented on web.');\n }\n async stop() {\n const video = document.getElementById('video');\n if (video) {\n video.pause();\n const st = video.srcObject;\n const tracks = st.getTracks();\n for (let i = 0; i < tracks.length; i++) {\n const track = tracks[i];\n track.stop();\n }\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve, _) => {\n const video = document.getElementById('video');\n const canvas = document.createElement('canvas');\n // video.width = video.offsetWidth;\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n let base64EncodedImage;\n if (options.quality != undefined) {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', options.quality / 100.0)\n .replace('data:image/jpeg;base64,', '');\n }\n else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async getSupportedFlashModes() {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n async setFlashMode(_options) {\n throw new Error('setFlashMode not supported under the web platform');\n }\n async flip() {\n throw new Error('flip not supported under the web platform');\n }\n async setOpacity(_options) {\n const video = document.getElementById('video');\n if (!!video && !!_options['opacity']) {\n video.style.setProperty('opacity', _options['opacity'].toString());\n }\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,aAAa,GAAGA,mBAAc,CAAC,eAAe,EAAE;AACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACpE,CAAC;;ACFM,MAAM,gBAAgB,SAASC,cAAS,CAAC;AAChD,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,CAAC;AACd,YAAY,IAAI,EAAE,eAAe;AACjC,YAAY,SAAS,EAAE,CAAC,KAAK,CAAC;AAC9B,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;AACzB,QAAQ,OAAO,IAAI,OAAO,CAAC,OAAO,OAAO,EAAE,MAAM,KAAK;AACtD,YAAY,MAAM,SAAS,CAAC,YAAY;AACxC,iBAAiB,YAAY,CAAC;AAC9B,gBAAgB,KAAK,EAAE,CAAC,OAAO,CAAC,YAAY;AAC5C,gBAAgB,KAAK,EAAE,IAAI;AAC3B,aAAa,CAAC;AACd,iBAAiB,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