This is an automated email from the ASF dual-hosted git repository.

erisu pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/cordova-plugin-media-capture.git


The following commit(s) were added to refs/heads/master by this push:
     new dfe3716  feat(ios): support capture 'quality' param for videos (#214)
dfe3716 is described below

commit dfe3716d34cae31fa263fa330eb6a5ee2330b4d1
Author: Alexis THOMAS <[email protected]>
AuthorDate: Mon Jul 31 18:50:07 2023 +0200

    feat(ios): support capture 'quality' param for videos (#214)
---
 README.md            | 11 ++++++++---
 src/ios/CDVCapture.m | 16 ++++++++++++++--
 2 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index e202375..7b4a3db 100644
--- a/README.md
+++ b/README.md
@@ -352,6 +352,8 @@ capturing a video clip, the `CaptureErrorCB` callback 
executes with a
 
 - __duration__: The maximum duration of a video clip, in seconds.
 
+- __quality__: To allow capturing video at different qualities.  A value of 
`1` ( the default ) means high quality and value of `0` means low quality, 
suitable for MMS messages.
+
 ### Example
 
     // limit capture operation to 3 video clips
@@ -363,12 +365,15 @@ capturing a video clip, the `CaptureErrorCB` callback 
executes with a
 
 - The __limit__ property is ignored.  Only one video is recorded per 
invocation.
 
+- The __quality__ property can have a value of `0.5` for medium quality.
+
+- See 
[here](https://developer.apple.com/documentation/uikit/uiimagepickercontroller/1619154-videoquality?language=objc)
 for more details about the __quality__ property on iOS.
+
 ### Android Quirks
 
-- Android supports an additional __quality__ property, to allow capturing 
video at different qualities.  A value of `1` ( the default ) means high 
quality and value of `0` means low quality, suitable for MMS messages.
-  See 
[here](http://developer.android.com/reference/android/provider/MediaStore.html#EXTRA_VIDEO_QUALITY)
 for more details.
+- See 
[here](http://developer.android.com/reference/android/provider/MediaStore.html#EXTRA_VIDEO_QUALITY)
 for more details about the __quality__ property on Android.
 
-### Example ( Android w/ quality )
+### Example ( w/ quality )
 
     // limit capture operation to 1 video clip of low quality
     var options = { limit: 1, quality: 0 };
diff --git a/src/ios/CDVCapture.m b/src/ios/CDVCapture.m
index d777a06..cf9b17e 100644
--- a/src/ios/CDVCapture.m
+++ b/src/ios/CDVCapture.m
@@ -220,9 +220,10 @@
         options = [NSDictionary dictionary];
     }
 
-    // options could contain limit, duration and mode
+    // options could contain limit, duration, quality and mode
     // taking more than one video (limit) is only supported if provide own 
controls via cameraOverlayView property
     NSNumber* duration = [options objectForKey:@"duration"];
+    NSNumber* quality = [options objectForKey:@"quality"];
     NSString* mediaType = nil;
 
     if ([UIImagePickerController 
isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
@@ -266,7 +267,18 @@
         // iOS 4.0
         if ([pickerController 
respondsToSelector:@selector(cameraCaptureMode)]) {
             pickerController.cameraCaptureMode = 
UIImagePickerControllerCameraCaptureModeVideo;
-            // pickerController.videoQuality = 
UIImagePickerControllerQualityTypeHigh;
+            switch ((int) (quality ? [quality doubleValue] * 10 : -1)) {
+                case 0:
+                    pickerController.videoQuality = 
UIImagePickerControllerQualityTypeLow;
+                    break;
+                case 5:
+                    pickerController.videoQuality = 
UIImagePickerControllerQualityTypeMedium;
+                    break;
+                case 10:
+                default:
+                    pickerController.videoQuality = 
UIImagePickerControllerQualityTypeHigh;
+                    break;
+            }
             // pickerController.cameraDevice = 
UIImagePickerControllerCameraDeviceRear;
             // pickerController.cameraFlashMode = 
UIImagePickerControllerCameraFlashModeAuto;
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to