@capacitor-community/camera-preview 1.1.3 → 2.0.0-beta.2

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.
@@ -1,13 +1,14 @@
1
1
 
2
2
  Pod::Spec.new do |s|
3
3
  s.name = 'CapacitorCommunityCameraPreview'
4
- s.version = '0.0.1'
4
+ s.version = '2.0.0'
5
5
  s.summary = 'Camera preview'
6
6
  s.license = 'MIT'
7
7
  s.homepage = 'https://github.com/capacitor-community/camera-preview.git'
8
8
  s.author = 'Ariel Hernandez Musa'
9
9
  s.source = { :git => 'https://github.com/capacitor-community/camera-preview.git', :tag => s.version.to_s }
10
10
  s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
11
- s.ios.deployment_target = '11.0'
11
+ s.ios.deployment_target = '12.0'
12
12
  s.dependency 'Capacitor'
13
+ s.swift_version = '5.1'
13
14
  end
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Ariel Hernandez Musa.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,8 +1,15 @@
1
- # Capacitor Camera Preview
1
+ <p align="center"><br><img src="https://user-images.githubusercontent.com/236501/85893648-1c92e880-b7a8-11ea-926d-95355b8175c7.png" width="128" height="128" /></p>
2
+ <h3 align="center">Capacitor Camera Preview</h3>
3
+ <p align="center"><strong><code>@capacitor-community/camera-preview</code></strong></p>
4
+ <br>
5
+ <p align="center"><strong>CAPACITOR 3</strong></p><br>
2
6
 
3
- Capacitor plugin that allows camera interaction from Javascript and HTML (based on cordova-plugin-camera-preview)
7
+ <p align="center">
8
+ Capacitor plugin that allows camera interaction from Javascript and HTML<br>(based on cordova-plugin-camera-preview).
9
+ </p>
10
+ <br>
4
11
 
5
- **Releases are being kept up to date when appropriate. However, this plugin is under constant development. As such it is recommended to use master to always have the latest fixes & features.**
12
+ Version 2 of this plugin is compatible with Ionic 5 and Capacitor 3. If your project uses Capacitor 2, please make sure you install [version 1](https://github.com/capacitor-community/camera-preview/releases/tag/v1.2.1) of this plugin.
6
13
 
7
14
  **PR's are greatly appreciated. Maintainer(s) wanted.**
8
15
 
@@ -23,22 +30,6 @@ Capacitor plugin that allows camera interaction from Javascript and HTML (based
23
30
 
24
31
  # Installation
25
32
 
26
- <!-- Use any one of the installation methods listed below depending on which framework you use. -->
27
-
28
- <!-- To install the master version with latest fixes and features -->
29
-
30
- <!-- ```
31
- cordova plugin add https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview.git
32
-
33
- ionic cordova plugin add https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview.git
34
-
35
- meteor add cordova:cordova-plugin-camera-preview@https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview.git#[latest_commit_id]
36
-
37
- <plugin spec="https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview.git" source="git" />
38
- ``` -->
39
-
40
- <!-- or if you want to use the last released version on npm -->
41
-
42
33
  ```
43
34
  yarn add @capacitor-community/camera-preview
44
35
 
@@ -51,44 +42,19 @@ Then run
51
42
  npx cap sync
52
43
  ```
53
44
 
54
- #### Android Quirks
55
-
56
- On Android remember to add the plugin to `MainActivity`
57
- ```java
58
- import com.ahm.capacitor.camera.preview.CameraPreview;
59
-
60
-
61
- this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
62
- // Additional plugins you've installed go here
63
- // Ex: add(TotallyAwesomePlugin.class);
64
- add(CameraPreview.class);
65
- }});
45
+ ## Extra Android installation steps
46
+ Open `android/app/src/main/AndroidManifest.xml` and above the closing `</manifest>` tag add this line to request the CAMERA permission:
47
+ ```xml
48
+ <uses-permission android:name="android.permission.CAMERA" />
66
49
  ```
50
+ For more help consult the [Capacitor docs](https://capacitorjs.com/docs/android/configuration#configuring-androidmanifestxml).
67
51
 
68
- #### Web Quirks
69
- 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
70
- <!--
71
- #### iOS Quirks
72
- If you are developing for iOS 10+ you must also add the following to your config.xml
52
+ ## Extra iOS installation steps
53
+ 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`.
73
54
 
74
- ```xml
75
- <config-file platform="ios" target="*-Info.plist" parent="NSCameraUsageDescription" overwrite="true">
76
- <string>Allow the app to use your camera</string>
77
- </config-file> -->
55
+ ## Extra Web installation steps
56
+ 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
78
57
 
79
- <!-- or for Phonegap -->
80
-
81
- <!-- <gap:config-file platform="ios" target="*-Info.plist" parent="NSCameraUsageDescription" overwrite="true">
82
- <string>Allow the app to use your camera</string>
83
- </gap:config-file>
84
- ``` -->
85
- <!--
86
- #### Android Quirks (older devices)
87
- When using the plugin for older devices, the camera preview will take the focus inside the app once initialized.
88
- In order to prevent the app from closing when a user presses the back button, the event for the camera view is disabled.
89
- If you still want the user to navigate, you can add a listener for the back event for the preview
90
- (see <code>[onBackButton](#onBackButton)</code>)
91
- -->
92
58
 
93
59
  # Methods
94
60
 
@@ -109,6 +75,8 @@ Starts the camera preview instance.
109
75
  | rotateWhenOrientationChanged | boolean | (optional) Rotate preview when orientation changes (applicable to the ios platforms only; default value is true) |
110
76
  | storeToFile | boolean | (optional) Capture images to a file and return back the file path instead of returning base64 encoded data, default false. |
111
77
  | disableExifHeaderStripping | boolean | (optional) Disable automatic rotation of the image, and let the browser deal with it, default true (applicable to the android and ios platforms only) |
78
+ | disableAudio | boolean | (optional) Disables audio stream to prevent permission requests, default false. (applicable to web only) |
79
+ | lockAndroidOrientation | boolean | (optional) Locks device orientation when camer is showing, default false. (applicable to Android only) |
112
80
 
113
81
  <!-- <strong>Options:</strong>
114
82
  All options stated are optional and will default to values here
@@ -145,7 +113,7 @@ ion-content {
145
113
  --background: transparent;
146
114
  }
147
115
  ```
148
- Take into account that this will make transparent all ion-content on application, if you want to show camera preview only in one page, just add a cutom class to your ion-content and make it transparent:
116
+ Take into account that this will make transparent all ion-content on application, if you want to show camera preview only in one page, just add a custom class to your ion-content and make it transparent:
149
117
 
150
118
  ```css
151
119
  .my-custom-camera-preview-content {
@@ -202,7 +170,7 @@ CameraPreview.hide();
202
170
  <!-- <info>Take the picture. If width and height are not specified or are 0 it will use the defaults. If width and height are specified, it will choose a supported photo size that is closest to width and height specified and has closest aspect ratio to the preview. The argument `quality` defaults to `85` and specifies the quality/compression value: `0=max compression`, `100=max quality`.</info><br/> -->
203
171
 
204
172
  ```javascript
205
- import { CameraPreviewFlashMode } from 'c@capacitor-community/camera-preview';
173
+ import { CameraPreviewFlashMode } from '@capacitor-community/camera-preview';
206
174
 
207
175
  const cameraPreviewPictureOptions: CameraPreviewPictureOptions = {
208
176
  quality: 50
@@ -215,6 +183,28 @@ const base64PictureData = result.value;
215
183
 
216
184
  ```
217
185
 
186
+ ### captureSample(options)
187
+
188
+ | Option | values | descriptions |
189
+ |----------|---------------|----------------------------------------------------------------------|
190
+ | quality | number | (optional) The picture quality, 0 - 100, default 85 |
191
+
192
+ <info>Captures a sample image from the video stream. Only for Android and iOS, web implementation falls back to `capture` method. This can be used to perform real-time analysis on the current frame in the video. The argument `quality` defaults to `85` and specifies the quality/compression value: `0=max compression`, `100=max quality`.</info><br/>
193
+
194
+ ```javascript
195
+ import { CameraSampleOptions } from '@capacitor-community/camera-preview';
196
+
197
+ const cameraSampleOptions: CameraSampleOptions = {
198
+ quality: 50
199
+ };
200
+
201
+ const result = await CameraPreview.captureSample(cameraSampleOptions);
202
+ const base64PictureData = result.value;
203
+
204
+ // do something with base64PictureData
205
+
206
+ ```
207
+
218
208
  ### getSupportedFlashModes()
219
209
 
220
210
  <info>Get the flash modes supported by the camera device currently started. Returns an array containing supported flash modes. See <code>[FLASH_MODE](#camera_Settings.FlashMode)</code> for possible values that can be returned</info><br/>
@@ -405,3 +395,5 @@ Created by Marcel Barbosa Pinto [@mbppower](https://github.com/mbppower)
405
395
  # Demo
406
396
 
407
397
  A working example can be found at [Demo](https://github.com/capacitor-community/camera-preview/tree/master/demo)
398
+
399
+ To run the demo on your local network and access media devices, a secure context is needed. Add an `.env` file at the root of the demo folder with `HTTPS=true` to start react with HTTPS.
@@ -11,10 +11,10 @@ buildscript {
11
11
  apply plugin: 'com.android.library'
12
12
 
13
13
  android {
14
- compileSdkVersion 28
14
+ compileSdkVersion 30
15
15
  defaultConfig {
16
16
  minSdkVersion 21
17
- targetSdkVersion 28
17
+ targetSdkVersion 30
18
18
  versionCode 1
19
19
  versionName "1.0"
20
20
  testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -40,8 +40,8 @@ repositories {
40
40
  dependencies {
41
41
  implementation fileTree(dir: 'libs', include: ['*.jar'])
42
42
  implementation project(':capacitor-android')
43
- implementation 'androidx.appcompat:appcompat:1.1.0'
44
- implementation 'androidx.exifinterface:exifinterface:1.0.0'
43
+ implementation 'androidx.appcompat:appcompat:1.3.0'
44
+ implementation 'androidx.exifinterface:exifinterface:1.3.2'
45
45
  testImplementation 'junit:junit:4.12'
46
46
  androidTestImplementation 'com.android.support.test:runner:1.0.2'
47
47
  androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
@@ -673,7 +673,17 @@ public class CameraActivity extends Fragment {
673
673
  degrees = 0;
674
674
  break;
675
675
  }
676
- params.setRotation(degrees);
676
+ int orientation;
677
+ Camera.CameraInfo info = new Camera.CameraInfo();
678
+ if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
679
+ orientation = (info.orientation + degrees) % 360;
680
+ if (degrees != 0) {
681
+ orientation = (360 - orientation) % 360;
682
+ }
683
+ } else {
684
+ orientation = (info.orientation - degrees + 360) % 360;
685
+ }
686
+ params.setRotation(orientation);
677
687
  } else {
678
688
  params.setRotation(mPreview.getDisplayOrientation());
679
689
  }