Giter Site home page Giter Site logo

apache / cordova-plugin-media-capture Goto Github PK

View Code? Open in Web Editor NEW
306.0 35.0 488.0 2.99 MB

Apache Cordova Media Capture Plugin

Home Page: https://cordova.apache.org/

License: Apache License 2.0

Java 22.62% JavaScript 47.25% Objective-C 30.12%
cordova library objective-c java nodejs javascript mobile android hacktoberfest ios

cordova-plugin-media-capture's Introduction

title description
Media Capture
Capture audio, video, and images.

cordova-plugin-media-capture

Android Testsuite Chrome Testsuite iOS Testsuite Lint Test

This plugin provides access to the device's audio, image, and video capture capabilities.

WARNING: Collection and use of images, video, or audio from the device's camera or microphone raises important privacy issues. Your app's privacy policy should discuss how the app uses such sensors and whether the data recorded is shared with any other parties. In addition, if the app's use of the camera or microphone is not apparent in the user interface, you should provide a just-in-time notice before the app accesses the camera or microphone (if the device operating system doesn't do so already). That notice should provide the same information noted above, as well as obtaining the user's permission (e.g., by presenting choices for OK and No Thanks). Note that some app marketplaces may require your app to provide just-in-time notice and obtain permission from the user prior to accessing the camera or microphone. For more information, please see the Privacy Guide.

This plugin defines global navigator.device.capture object.

Although in the global scope, it is not available until after the deviceready event.

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    console.log(navigator.device.capture);
}

Installation

cordova plugin add cordova-plugin-media-capture

Supported Platforms

  • Android
  • Browser
  • iOS
  • Windows

Objects

  • Capture
  • CaptureAudioOptions
  • CaptureImageOptions
  • CaptureVideoOptions
  • CaptureCallback
  • CaptureErrorCB
  • ConfigurationData
  • MediaFile
  • MediaFileData

Methods

  • capture.captureAudio
  • capture.captureImage
  • capture.captureVideo
  • MediaFile.getFormatData

Properties

  • supportedAudioModes: The audio recording formats supported by the device. (ConfigurationData[])

  • supportedImageModes: The recording image sizes and formats supported by the device. (ConfigurationData[])

  • supportedVideoModes: The recording video resolutions and formats supported by the device. (ConfigurationData[])

capture.captureAudio

Start the audio recorder application and return information about captured audio clip files.

navigator.device.capture.captureAudio(
    CaptureCB captureSuccess, CaptureErrorCB captureError,  [CaptureAudioOptions options]
);

Description

Starts an asynchronous operation to capture audio recordings using the device's default audio recording application. The operation allows the device user to capture multiple recordings in a single session.

The capture operation ends when either the user exits the audio recording application, or the maximum number of recordings specified by CaptureAudioOptions.limit is reached. If no limit parameter value is specified, it defaults to one (1), and the capture operation terminates after the user records a single audio clip.

When the capture operation finishes, the CaptureCallback executes with an array of MediaFile objects describing each captured audio clip file. If the user terminates the operation before an audio clip is captured, the CaptureErrorCallback executes with a CaptureError object, featuring the CaptureError.CAPTURE_NO_MEDIA_FILES error code.

Supported Platforms

  • Android
  • iOS
  • Windows

Example

// capture callback
var captureSuccess = function(mediaFiles) {
    var i, path, len;
    for (i = 0, len = mediaFiles.length; i < len; i += 1) {
        path = mediaFiles[i].fullPath;
        // do something interesting with the file
    }
};

// capture error callback
var captureError = function(error) {
    navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
};

// start audio capture
navigator.device.capture.captureAudio(captureSuccess, captureError, {limit:2});

iOS Quirks

  • iOS does not have a default audio recording application, so a simple user interface is provided.

Windows Phone 7 and 8 Quirks

  • Windows Phone 7 does not have a default audio recording application, so a simple user interface is provided.

capture.captureImage

Start the camera application and return information about captured image files.

navigator.device.capture.captureImage(
    CaptureCB captureSuccess, CaptureErrorCB captureError, [CaptureImageOptions options]
);

Description

Starts an asynchronous operation to capture images using the device's camera application. The operation allows users to capture more than one image in a single session.

The capture operation ends either when the user closes the camera application, or the maximum number of recordings specified by CaptureImageOptions.limit is reached. If no limit value is specified, it defaults to one (1), and the capture operation terminates after the user captures a single image.

When the capture operation finishes, it invokes the CaptureCB callback with an array of MediaFile objects describing each captured image file. If the user terminates the operation before capturing an image, the CaptureErrorCB callback executes with a CaptureError object featuring a CaptureError.CAPTURE_NO_MEDIA_FILES error code.

Supported Platforms

  • Android
  • Browser
  • iOS
  • Windows

iOS Quirks

Since iOS 10 it's mandatory to provide an usage description in the info.plist if trying to access privacy-sensitive data. When the system prompts the user to allow access, this usage description string will displayed as part of the permission dialog box, but if you didn't provide the usage description, the app will crash before showing the dialog. Also, Apple will reject apps that access private data but don't provide an usage description.

This plugins requires the following usage descriptions:

  • NSCameraUsageDescription describes the reason the app accesses the user's camera.
  • NSMicrophoneUsageDescription describes the reason the app accesses the user's microphone.
  • NSPhotoLibraryUsageDescriptionentry describes the reason the app accesses the user's photo library.

To add these entries into the info.plist, you can use the edit-config tag in the config.xml like this:

<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge">
    <string>need camera access to take pictures</string>
</edit-config>
<edit-config target="NSMicrophoneUsageDescription" file="*-Info.plist" mode="merge">
    <string>need microphone access to record sounds</string>
</edit-config>
<edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge">
    <string>need to photo library access to get pictures from there</string>
</edit-config>

Browser Quirks

Works in Chrome, Firefox and Opera only (since IE and Safari doesn't supports navigator.getUserMedia API)

Displaying images using captured file's URL available in Chrome/Opera only. Firefox stores captured images in IndexedDB storage (see File plugin documentation), and due to this the only way to show captured image is to read it and show using its DataURL.

Example

// capture callback
var captureSuccess = function(mediaFiles) {
    var i, path, len;
    for (i = 0, len = mediaFiles.length; i < len; i += 1) {
        path = mediaFiles[i].fullPath;
        // do something interesting with the file
    }
};

// capture error callback
var captureError = function(error) {
    navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
};

// start image capture
navigator.device.capture.captureImage(captureSuccess, captureError, {limit:2});

capture.captureVideo

Start the video recorder application and return information about captured video clip files.

navigator.device.capture.captureVideo(
    CaptureCB captureSuccess, CaptureErrorCB captureError, [CaptureVideoOptions options]
);

Description

Starts an asynchronous operation to capture video recordings using the device's video recording application. The operation allows the user to capture more than one recordings in a single session.

The capture operation ends when either the user exits the video recording application, or the maximum number of recordings specified by CaptureVideoOptions.limit is reached. If no limit parameter value is specified, it defaults to one (1), and the capture operation terminates after the user records a single video clip.

When the capture operation finishes, it the CaptureCB callback executes with an array of MediaFile objects describing each captured video clip file. If the user terminates the operation before capturing a video clip, the CaptureErrorCB callback executes with a CaptureError object featuring a CaptureError.CAPTURE_NO_MEDIA_FILES error code.

Supported Platforms

  • Android
  • iOS
  • Windows

Example

// capture callback
var captureSuccess = function(mediaFiles) {
    var i, path, len;
    for (i = 0, len = mediaFiles.length; i < len; i += 1) {
        path = mediaFiles[i].fullPath;
        // do something interesting with the file
    }
};

// capture error callback
var captureError = function(error) {
    navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
};

// start video capture
navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:2});

CaptureAudioOptions

Encapsulates audio capture configuration options.

Properties

  • limit: The maximum number of audio clips the device user can record in a single capture operation. The value must be greater than or equal to 1 (defaults to 1).

  • duration: The maximum duration of an audio sound clip, in seconds.

Example

// limit capture operation to 3 media files, no longer than 10 seconds each
var options = { limit: 3, duration: 10 };

navigator.device.capture.captureAudio(captureSuccess, captureError, options);

Android Quirks

  • The duration parameter is not supported. Recording lengths can't be limited programmatically.

iOS Quirks

  • The limit parameter is not supported, so only one recording can be created for each invocation.

CaptureImageOptions

Encapsulates image capture configuration options.

Properties

  • limit: The maximum number of images the user can capture in a single capture operation. The value must be greater than or equal to 1 (defaults to 1).

Example

// limit capture operation to 3 images
var options = { limit: 3 };

navigator.device.capture.captureImage(captureSuccess, captureError, options);

iOS Quirks

  • The limit parameter is not supported, and only one image is taken per invocation.

CaptureVideoOptions

Encapsulates video capture configuration options.

Properties

  • limit: The maximum number of video clips the device's user can capture in a single capture operation. The value must be greater than or equal to 1 (defaults to 1).

  • 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
var options = { limit: 3 };

navigator.device.capture.captureVideo(captureSuccess, captureError, options);

iOS Quirks

  • 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 for more details about the quality property on iOS.

Android Quirks

  • See here for more details about the quality property on Android.

Example ( w/ quality )

// limit capture operation to 1 video clip of low quality
var options = { limit: 1, quality: 0 };
navigator.device.capture.captureVideo(captureSuccess, captureError, options);

CaptureCB

Invoked upon a successful media capture operation.

function captureSuccess( MediaFile[] mediaFiles ) { ... };

Description

This function executes after a successful capture operation completes. At this point a media file has been captured, and either the user has exited the media capture application, or the capture limit has been reached.

Each MediaFile object describes a captured media file.

Example

// capture callback
function captureSuccess(mediaFiles) {
    var i, path, len;
    for (i = 0, len = mediaFiles.length; i < len; i += 1) {
        path = mediaFiles[i].fullPath;
        // do something interesting with the file
    }
};

CaptureError

Encapsulates the error code resulting from a failed media capture operation.

Properties

  • code: One of the pre-defined error codes listed below.

Constants

  • CaptureError.CAPTURE_INTERNAL_ERR: The camera or microphone failed to capture image or sound.

  • CaptureError.CAPTURE_APPLICATION_BUSY: The camera or audio capture application is currently serving another capture request.

  • CaptureError.CAPTURE_INVALID_ARGUMENT: Invalid use of the API (e.g., the value of limit is less than one).

  • CaptureError.CAPTURE_NO_MEDIA_FILES: The user exits the camera or audio capture application before capturing anything.

  • CaptureError.CAPTURE_PERMISSION_DENIED: The user denied a permission required to perform the given capture request.

  • CaptureError.CAPTURE_NOT_SUPPORTED: The requested capture operation is not supported.

CaptureErrorCB

Invoked if an error occurs during a media capture operation.

function captureError( CaptureError error ) { ... };

Description

This function executes if an error occurs when trying to launch a media capture operation. Failure scenarios include when the capture application is busy, a capture operation is already taking place, or the user cancels the operation before any media files are captured.

This function executes with a CaptureError object containing an appropriate error code.

Example

// capture error callback
var captureError = function(error) {
    navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
};

ConfigurationData

Encapsulates a set of media capture parameters that a device supports.

Description

Describes media capture modes supported by the device. The configuration data includes the MIME type, and capture dimensions for video or image capture.

The MIME types should adhere to RFC2046. Examples:

  • video/3gpp
  • video/quicktime
  • image/jpeg
  • audio/amr
  • audio/wav

Properties

  • type: The ASCII-encoded lowercase string representing the media type. (DOMString)

  • height: The height of the image or video in pixels. The value is zero for sound clips. (Number)

  • width: The width of the image or video in pixels. The value is zero for sound clips. (Number)

Example

// retrieve supported image modes
var imageModes = navigator.device.capture.supportedImageModes;

// Select mode that has the highest horizontal resolution
var width = 0;
var selectedmode;
for each (var mode in imageModes) {
    if (mode.width > width) {
        width = mode.width;
        selectedmode = mode;
    }
}

Not supported by any platform. All configuration data arrays are empty.

MediaFile.getFormatData

Retrieves format information about the media capture file.

mediaFile.getFormatData(
    MediaFileDataSuccessCB successCallback,
    [MediaFileDataErrorCB errorCallback]
);

Description

This function asynchronously attempts to retrieve the format information for the media file. If successful, it invokes the MediaFileDataSuccessCB callback with a MediaFileData object. If the attempt fails, this function invokes the MediaFileDataErrorCB callback.

Supported Platforms

  • Android
  • iOS
  • Windows

Android Quirks

The API to access media file format information is limited, so not all MediaFileData properties are supported.

iOS Quirks

The API to access media file format information is limited, so not all MediaFileData properties are supported.

MediaFile

Encapsulates properties of a media capture file.

Properties

  • name: The name of the file, without path information. (DOMString)

  • fullPath: The full path of the file, including the name. (DOMString)

  • type: The file's mime type (DOMString)

  • lastModifiedDate: The date and time when the file was last modified. (Date)

  • size: The size of the file, in bytes. (Number)

Methods

  • MediaFile.getFormatData: Retrieves the format information of the media file.

MediaFileData

Encapsulates format information about a media file.

Properties

  • codecs: The actual format of the audio and video content. (DOMString)

  • bitrate: The average bitrate of the content. The value is zero for images. (Number)

  • height: The height of the image or video in pixels. The value is zero for audio clips. (Number)

  • width: The width of the image or video in pixels. The value is zero for audio clips. (Number)

  • duration: The length of the video or sound clip in seconds. The value is zero for images. (Number)

Android Quirks

Supports the following MediaFileData properties:

  • codecs: Not supported, and returns null.

  • bitrate: Not supported, and returns zero.

  • height: Supported: image and video files only.

  • width: Supported: image and video files only.

  • duration: Supported: audio and video files only.

iOS Quirks

Supports the following MediaFileData properties:

  • codecs: Not supported, and returns null.

  • bitrate: Supported on iOS4 devices for audio only. Returns zero for images and videos.

  • height: Supported: image and video files only.

  • width: Supported: image and video files only.

  • duration: Supported: audio and video files only.

Android Lifecycle Quirks

When capturing audio, video, or images on the Android platform, there is a chance that the application will get destroyed after the Cordova Webview is pushed to the background by the native capture application. See the Android Lifecycle Guide for a full description of the issue. In this case, the success and failure callbacks passed to the capture method will not be fired and instead the results of the call will be delivered via a document event that fires after the Cordova resume event.

In your app, you should subscribe to the two possible events like so:

function onDeviceReady() {
    // pendingcaptureresult is fired if the capture call is successful
    document.addEventListener('pendingcaptureresult', function(mediaFiles) {
        // Do something with result
    });

    // pendingcaptureerror is fired if the capture call is unsuccessful
    document.addEventListener('pendingcaptureerror', function(error) {
        // Handle error case
    });
}

// Only subscribe to events after deviceready fires
document.addEventListener('deviceready', onDeviceReady);

It is up you to track what part of your code these results are coming from. Be sure to save and restore your app's state as part of the pause and resume events as appropriate. Please note that these events will only fire on the Android platform and only when the Webview was destroyed during a capture operation.

cordova-plugin-media-capture's People

Contributors

agrieve avatar alsorokin avatar ath0mas avatar bennmapes avatar clelland avatar cmarcelk avatar dblotsky avatar erisu avatar filmaj avatar hardeep avatar hermwong avatar infil00p avatar jamesjong avatar janpio avatar jcesarmobile avatar larrybahr avatar ldeluca avatar macdonst avatar matrosov-nikita avatar maverickmishra avatar purplecabbage avatar riknoll avatar sgrebnov avatar shazron avatar stacic avatar stevengill avatar t1st3 avatar timbru31 avatar timkim avatar vladimir-kotikov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-media-capture's Issues

[iPhone 11 Pro Max][iOS 13.3] App Crashes Immediately When Calling navigator.device.capture.captureVideo

Bug Report

Problem

On iOS 13.3 (iPhone 11 Pro Max) the app immediately crashes upon calling navigator.device.capture.captureVideo.

What is expected to happen?

The video capturing should start.

What does actually happen?

App crashes.

Information

Command or Code

Here is my full code for Cordova:

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
var app = {
    // Application Constructor
    initialize: function() {
        document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
    },

    // deviceready Event Handler
    //
    // Bind any cordova events here. Common events are:
    // 'pause', 'resume', etc.
    onDeviceReady: function() {
        this.receivedEvent('deviceready');
        start();
    },

    // Update DOM on a Received Event
    receivedEvent: function(id) {
        var parentElement = document.getElementById(id);
        var listeningElement = parentElement.querySelector('.listening');
        var receivedElement = parentElement.querySelector('.received');

        listeningElement.setAttribute('style', 'display:none;');
        receivedElement.setAttribute('style', 'display:block;');

        console.log('Received Event: ' + id);
    }
};

app.initialize();

async function start() {
    /*
    cordova.plugins.notification.local.schedule({
        title: 'ayy lmao',
        text: 'ayy lmao',
        foreground: true
    });
    */

    // capture callback
    var captureSuccess = function(mediaFiles) {
        /*
        var i, path, len;
        for (i = 0, len = mediaFiles.length; i < len; i += 1) {
            path = mediaFiles[i].fullPath;
            // do something interesting with the file
        }
        */
    };

    // capture error callback
    var captureError = function(error) {

        //navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
    };

    // start video capture
    navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:1});
}

Environment, Platform, Device

Mojave 10.14.6 (18G103)
iOS 13.3 (iPhone 11 Pro Max)

Version information

iOS 13.3 (iPhone 11 Pro Max)
Cordova CLI
Xcode

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

No Accept/Reject-Interface after recording a video, exception thrown when going back to app

Bug Report

Problem

After requesting and recording a video, no "accept"/"reject"/hook/cross -or whatever- button is showing, so the user does not know what to do.
When using the hardware back button the app receives an exception with code 3 "Canceled" as if the recording was canceled, even though a recording was made.

What is expected to happen?

Any interface telling the user what to do with the video and how to return to the app like the X and the check mark or the "use video" and "retake" in iOS showing.

What does actually happen?

Nothing.

Information

Tested with an Android 6-Phone and there cross and the check mark appear after having a video recorded.

As long as there is no way to go back into the app without triggering the code-3-cancel-error there is no way to get a video.

Command or Code

let options: CaptureVideoOptions = {
    duration: this.targetVideoLength,
    limit: 1
};
let data = await this.mediaCapture.captureVideo(options);

Environment, Platform, Device

  • Nokia 3 & Nokia 6.1, Both Android 9

Version information

Ionic:

   Ionic CLI          : 5.4.5 (/usr/local/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.9
   @ionic/app-scripts : 3.2.4

Cordova:

   Cordova CLI       : 9.0.0 ([email protected])
   Cordova Platforms : android 8.1.0, ios 5.0.1
   Cordova Plugins   : cordova-plugin-ionic-webview 2.5.2, (and 18 other plugins)

    "cordova-plugin-media-capture": "3.0.2",


Utility:

   cordova-res : 0.6.0 (update available: 0.8.1)
   native-run  : 0.2.9 

System:

   Android SDK Tools : 26.1.1 (/Users/jpf/Library/Android/sdk)
   ios-deploy        : 1.9.4
   ios-sim           : 8.0.2
   NodeJS            : v12.6.0 (/usr/local/Cellar/node/12.6.0/bin/node)
   npm               : 6.10.2
   OS                : macOS Catalina
   Xcode             : Xcode 11.2 Build version 11B52

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

3.0.3 available on npm

Feature Request

Would be nice if v 3.0.3 was available on npm

Motivation Behind Feature

Would like to use latest version with fixes

iOS - Media Files are stored in tmp

Good Day!

In iOS, the media file is stored in the 'tmp' directory. The file in the 'tmp' has a different name and size compared to the file that is found in the Photos app. I need to get the original file or file path with the correct file size and send it to a server. In android, it worked like a charm and I was able to get the original file.

Thank you!

How to initialize sampling rate in cordova-plugin-media-capture?

Bug Report

iPhone sampling rate starts wrong and later 'corrects itself'

Problem

Using the plugin I record and playback audio. On my iPad everything is fine. On the iPhone the sampling rate changes between the first recording and subsequent recordings. How can I initialize the app so that all recordings are at 44100Hz?

What is expected to happen?

On my iPhone (and iPad) I expect a constant sampling rate of 44100Hz.

What does actually happen?

On my iPad (iOS 12.+) everything works as expected. On my iPhone (iOS 12.+) the first recording takes place at a sampling rate of 48000Hz. Subsequent recordings are at the desired rate of 44100Hz.

Information

I verified this using an external tone of 1000Hz and spectral analysis on the two devices. The analysis shows a frequency of 1000Hz on the iPad but the first time on the iPhone this frequency is 918.75HZ = 1000*(44100/48000). For the record, the same cordova-generated app is run on both devices, no error messages are generated, and I do not change the sampling rate on the iPhone. It happens “by itself” through the plugin.

Command or Code

function audioMedia(val) {
mediaType = 'audio';
var audioNum = val;
myAudio = null;

// captureAudioSuccess callback
var captureAudioSuccess = function(mediaFiles) {
	acquired[audioNum] = true;
	var path = null;
	var len = mediaFiles.length;
	for (var i = 0; i < len; i++) {
		path = mediaFiles[i].fullPath;
		console.log('media full path = '+path, len);
		readMedia(mediaFiles[0].name,audioNum);
		}
	};
// captureAudioError callback
var captureAudioError = function(error) {
	alert('No audio was recorded. Try again?');
	};
// start audio capture
navigator.device.capture.captureAudio(captureAudioSuccess, captureAudioError, audioOptions);
};

Environment, Platform, Device

iPhone 6s, iPhone 7

Version information

cordova: 9.0.0 ([email protected])
From my config.xml file: "cordova-plugin-media-capture" spec="^3.0.2"

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Video capture pause button

Is there any way to disable the pause button during video capture as I wanted to capture video continuously

Camera app crashing

Hi,

I'm using the plugin version 3.0.2 with a Samsung Galaxy S7 and Android 8.0.0.

Sometimes when I'm using the capture.captureImage function with the limit of 9, the camera app crashes after a couple of photos taken with the same capture operation. I noticed that if I reduce the limit option to 1, the camera app doesn't crash anymore.

I've gathered a couple of exceptions and interesting logs that showed up on Logcat during this crashes. Those are:

08-15 11:19:17.528 28237 28237 E AndroidRuntime: FATAL EXCEPTION: main
08-15 11:19:17.528 28237 28237 E AndroidRuntime: Process: com.sec.android.app.camera, PID: 28237
08-15 11:19:17.528 28237 28237 E AndroidRuntime: java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.BATTERY_CHANGED flg=0x60000010 (has extras) } in com.sec.android.app.camera.provider.CameraTemperatureManager$1@cdd2e9f
08-15 11:19:17.528 28237 28237 E AndroidRuntime: 	at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_52226(LoadedApk.java:1329)
08-15 11:19:17.528 28237 28237 E AndroidRuntime: 	at android.app.-$Lambda$FilBqgnXJrN9Mgyks1XHeAxzSTk.$m$0(Unknown Source:4)
08-15 11:19:17.528 28237 28237 E AndroidRuntime: 	at android.app.-$Lambda$FilBqgnXJrN9Mgyks1XHeAxzSTk.run(Unknown Source:0)
08-15 11:19:17.528 28237 28237 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:789)
08-15 11:19:17.528 28237 28237 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:98)
08-15 11:19:17.528 28237 28237 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:164)
08-15 11:19:17.528 28237 28237 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:6944)
08-15 11:19:17.528 28237 28237 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
08-15 11:19:17.528 28237 28237 E AndroidRuntime: 	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
08-15 11:19:17.528 28237 28237 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
08-15 11:19:17.528 28237 28237 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'boolean com.sec.android.app.camera.interfaces.CameraContext.isDestroying()' on a null object reference
08-15 11:19:17.528 28237 28237 E AndroidRuntime: 	at com.sec.android.app.camera.provider.CameraTemperatureManager$1.onReceive(CameraTemperatureManager.java:76)
08-15 11:19:17.528 28237 28237 E AndroidRuntime: 	at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_52226(LoadedApk.java:1319)
08-15 11:19:17.528 28237 28237 E AndroidRuntime: 	... 9 more
08-15 11:59:52.650 27329 30945 E ImageFeatures: [#CMH#] applyJustShotFlag : java.io.FileNotFoundException: /storage/emulated/0/Pictures/1534327192619.jpg (No such file or directory) (/storage/emulated/0/Pictures/1534327192619.jpg (No such file or directory))
08-15 11:59:52.650 27329 30945 E ImageFeatures: 	at java.io.FileInputStream.open0 (FileInputStream.java:-2)
08-15 11:59:52.650 27329 30945 E ImageFeatures: 	at java.io.FileInputStream.open (FileInputStream.java:200)
08-15 11:59:52.650 27329 30945 E ImageFeatures: 	at java.io.FileInputStream.<init> (FileInputStream.java:150)
08-15 11:59:52.650 27329 30945 E ImageFeatures: 	at java.io.FileInputStream.<init> (FileInputStream.java:103)
08-15 11:59:52.650 27329 30945 E ImageFeatures: 	at android.media.ExifInterface.<init> (ExifInterface.java:1329)
08-15 11:59:52.650 27329 30945 E ImageFeatures: 	at com.samsung.cmh.features.ImageFeatures.isJustShot (ImageFeatures.java:54)
08-15 11:59:52.650 27329 30945 E ImageFeatures: 	at com.samsung.cmh.core.Controller.processInsertAction (Controller.java:2544)
08-15 11:59:52.650 27329 30945 E ImageFeatures: 	at com.samsung.cmh.core.Controller.execute (Controller.java:991)
08-15 11:59:52.650 27329 30945 E ImageFeatures: 	at com.samsung.cmh.service.CMHService.onHandleIntent (CMHService.java:100)
08-15 11:59:52.650 27329 30945 E ImageFeatures: 	at android.app.IntentService$ServiceHandler.handleMessage (IntentService.java:68)
08-15 11:59:52.650 27329 30945 E ImageFeatures: 	at android.os.Handler.dispatchMessage (Handler.java:105)
08-15 11:59:52.650 27329 30945 E ImageFeatures: 	at android.os.Looper.loop (Looper.java:164)
08-15 11:59:52.650 27329 30945 E ImageFeatures: 	at android.os.HandlerThread.run (HandlerThread.java:65)
08-15 11:59:52.650 27329 30945 E ImageFeatures:  
08-15 11:56:26.329  3292 28336 E ExynosCameraMemoryAllocator: @@@@ERR(alloc):*bufHandle == NULL failed
08-15 11:56:26.329  3292 28336 E ExynosCameraMemoryAllocator: ERR(dequeueBuffer):alloc failed
08-15 11:56:26.329  3292 28336 E ExynosCameraBufferManager: [CAM_ID(0)][PREVIEW_BUF]-ERR(m_bufferCollectorThreadFunc[2641]):dequeueBuffer failed, dequeue(6), collected(4)
08-15 11:56:26.329  3191  3215 E BufferQueueProducer: [SurfaceView - com.sec.android.app.camera/com.sec.android.app.camera.Camera@4c2063b@0#0] dequeueBuffer: BufferQueue has been abandoned
08-15 11:56:26.329  3292 28336 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
08-15 11:56:26.329  3191  3215 E BufferQueueProducer: [SurfaceView - com.sec.android.app.camera/com.sec.android.app.camera.Camera@4c2063b@0#0] dequeueBuffer: BufferQueue has been abandoned
08-15 11:56:26.329  3292 28336 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
08-15 11:56:26.329  3191  3215 E BufferQueueProducer: [SurfaceView - com.sec.android.app.camera/com.sec.android.app.camera.Camera@4c2063b@0#0] dequeueBuffer: BufferQueue has been abandoned
08-15 11:56:26.330  3292 28336 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
08-15 11:56:26.330  3191  3215 E BufferQueueProducer: [SurfaceView - com.sec.android.app.camera/com.sec.android.app.camera.Camera@4c2063b@0#0] dequeueBuffer: BufferQueue has been abandoned
08-15 11:56:26.330  3292 28336 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed
08-15 11:56:26.330  3191  3215 E BufferQueueProducer: [SurfaceView - com.sec.android.app.camera/com.sec.android.app.camera.Camera@4c2063b@0#0] dequeueBuffer: BufferQueue has been abandoned
08-15 11:56:26.330  3292 28336 E ExynosCameraMemoryAllocator: ERR(alloc):dequeue_buffer failed

The same app with the capture limit set to 9 doesn't crash in a Samsung Galaxy J5 with Android 7.0.
My cordova-plugin-file, which is a dependency of this plugin, is at version 6.0.1.

I have this permissions requested in my app: cordova.plugins.permissions.ACCESS_FINE_LOCATION, cordova.plugins.permissions.CAMERA, cordova.plugins.permissions.READ_EXTERNAL_STORAGE, cordova.plugins.permissions.WRITE_EXTERNAL_STORAGE.

Any ideas here? I'm missing something?

Event when video capture starts

In our application we would need to get informed in the moment the user starts pressing the record button.

Our usecase: we are recording the current geoposition while capturing the video, so we need the exact time when the user starts and stops.

Is there any kind of event or a callback which gets called when the user actually presses the record button?

File .MOV corrupted

Hello,

On IOS, when we get the media file, after the record, the file generated seems ok, but in fact, if we use the parameter fullPath as local path in order to upload the file on a server by FTP, the file uploaded on the server is not whole.

I think that there's is a bug , could you check please?

Best regards

media capture disabling storage

Bug Report

Problem

the plug in has over ridden and disabled @ionic/storage and am now unable to persist data

What is expected to happen?

not to delete data and be able to use the plugin

What does actually happen?

while implementing an option to select a photo from their device I installed the newest version of the plug in and the npm package. After install my application was restarted and any and all data that was stored related to the application was wiped out. Now I am unable to persist any data, even after removing the plugin and npm package

Information

Command or Code

$ ionic cordova plugin add cordova-plugin-media-capture
$ npm install @ionic-native/media-capture

Environment, Platform, Device

Android device, Ionic 4, Angular 7

Version information

OS Mojave 10.14
ionic 4
Angular 7

Checklist

  • [ x] I searched for existing GitHub issues
  • [x ] I updated all Cordova tooling to most recent version
  • [ x] I included all the necessary information above

NSInvalidArgumentException - App crashes when CaptureImage is called

Bug Report

Hi guys,

recently I am facing the Issue that my app crashes when I am trying to call the function "captureImage". The function did in fact work for quite some time, so I don't actually know why it doesn't anymore.

`
function captureImage(storePath) {

try {
    var newPath = storePath;
    var captureSuccess = function (mediaFiles) {
        var i, path, len;
        for (i = 0, len = mediaFiles.length; i < len; i += 1) {
            path = mediaFiles[i].fullPath;
            let name = new Date().getTime();
            moveFile(path, FILE_DIRECTORY + newPath, name + ".jpg");
        }
    };
    // capture error callback
    var captureError = function (error) {
        navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
    };
    // start image capture
    navigator.device.capture.captureImage(captureSuccess, captureError, { limit: 1 });
} catch(e) {
    console.log(e);
}

}
`

The app doesn't even Catch the exception. Instead it just crashes. And leaves me this error-message:

"*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <MainViewController: 0x101513700>.'"

The "NSInvalidArgumentException" kinda confuses me a bit, as it seems like I am passing some wrong functions for success and error. But as mentioned before this code worked for me like for more than a year and I did not change anything since then.

Cordova version: 9.0.0
Cordova-Ins version: 4.5.5
iOS Version: 13.2.3
Device: iPad (6. Gen)

Android video capture size does not reduce using "quality" option while capturing video

Apache Cordova uses GitHub Issues as a feature request and bug tracker only.
For usage and support questions, please check out the resources below. Thanks!


You can get answers to your usage and support questions about Apache Cordova on:


If you are using a tool that uses Cordova internally, like e.g. Ionic, check their support channels:

opening device's audio video recorder

I want to make audio video recorder but this plugin is opening the device's audio/video recorder
please help with this I do not want to use device's audio/video recorder I want my app should record the media

ERROR TypeError: Object(...) is not a function

I just created a helloWord with the lib example, but I get the following error

HomePage.html:13 ERROR TypeError: Object(...) is not a function at MediaCapture.captureImage (vendor.js:81002) at HomePage.webpackJsonp.251.HomePage.meuTeste (main.js:175) at Object.eval [as handleEvent] (HomePage.html:13) at handleEvent (vendor.js:14225) at callWithDebugContext (vendor.js:15734) at Object.debugHandleEvent [as handleEvent] (vendor.js:15321) at dispatchEvent (vendor.js:10640) at vendor.js:11265 at HTMLButtonElement.<anonymous> (vendor.js:40129) at t.invokeTask (polyfills.js:3)

Ionic Framework: 3.9.3
Ionic App Scripts: 3.2.1
Angular Core: 5.2.11
Angular Compiler CLI: 5.2.11
Node: 10.15.1
OS Platform: Windows 10
Navigator Platform: Win32
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.96 Safari/537.36

Windows mobile 10

Hi,
is the plugin working on Windows Mobile 10. I'm getting the following error : "plugin not installed"
even that the plugin is installed.
cordova-plugin-media-capture 3.0.2 "Capture"
Same app is working fine on iOS, Andorid !?

Device gallery shows pictures - Android

Hello guys,

Im using this plugin to capture video, the videos are recorded properly and so is the videoURL returned. I move the file to a private location and encrypt it afterwards.

My question is related to the Android gallery app, even after moving he file, it appears on the gallery miniatures and fortunately an error is thrown "File not found".

How do i prevent that gallery miniature?

Can i take multiple pictures from photogallery?

Hi everyone,

First of all thanks for the plugin, I would like to know if i could use this plugin for to get multiple pictures from photogallery to be uploaded on Ionic 4 through Firebase.

Thank you so much

Regards

iOS 13 bug?

It seems like we may be experience the same bug that Cordova-Plugin-Camera is experiencing.

apache/cordova-plugin-camera#506

Any thoughts on a fix?

My localURL is

cdvfile://localhost/temporary/59284040337__0D7B9C83-F037-4886-A92A-064688556823.MOV

and the fullPath is

/private/var/mobile/Containers/Data/Application/021133A7-158B-4EDE-8EDD-CB330EBC21E2/tmp/59284040337__0D7B9C83-F037-4886-A92A-064688556823.MOV

I'm trying to get the videos up to FireBase, but this seems to be a corrupted file. See full mediaFile output here:

end: 0
fullPath: "/private/var/mobile/Containers/Data/Application/2802BF6F-AF3B-472A-ADB4-D14463487C42/tmp/59284400184__ABFE96DC-550B-46F1-AEBF-5DE5F7F17F7A.M…"
lastModified: null
lastModifiedDate: 1571151205370.55
localURL: "cdvfile://localhost/temporary/59284400184__ABFE96DC-550B-46F1-AEBF-5DE5F7F17F7A.MOV"
name: "59284400184__ABFE96DC-550B-46F1-AEBF-5DE5F7F17F7A.MOV"
size: 3672746
start: 0
type: "video/quicktime"

Video Focus

Hello,

I'm trying to take a video on an iPhone but the resolution is poor, see example here
Video with native Camera app:
test1
Video within the app, via the plugin:
test2

I feel like the focus isn't working because the quality is fine if I get closer to the object.
This only happens on iOS, Android is fine

Consider adding the repo on issuehunt.io

Why dont you consider adding the repo on issuehunt.io so that the business community that actually uses the plugin and profits from it, can help with bug fixing? The precious open source developers who work to support and solve the bugs or create new features, need a basic incentive.

That is what react native is actually doing and from what I see it is actually working!
https://github.com/react-native-community/react-native-camera

Developers actually need to be rewarded I think for their time.
I think it is pure logic.
We all want to help the open source community but sometimes the only way for a non-developer is to give the incentive to another developer to solve a bug.

Please consider it!

[Android 10 | 9] Transcode Error

Bug Report

Problem

What is expected to happen?

It should not throw error and compress successfully.

What does actually happen?

net.ypresto.androidtranscoder.engine.InvalidOutputFormatException: Non-baseline AVC video profile is not supported by Android OS, actual profile_idc: 100

Information

Command or Code

this._videoEditor.transcodeVideo({
fileUri: file,
outputFileName: 'video-output-' + new Date().getTime().toString(),
saveToLibrary: false,
optimizeForNetworkUse: this._videoEditor.OptimizeForNetworkUse.YES,
outputFileType: this._videoEditor.OutputFileType.MPEG4
}).then((fileUri: string) => {
this._shared.Loader.hide();
setTimeout(() => {
this.uploadFile(fileUri, 'video');
}, 500);
})

Environment, Platform, Device

Device: Moto one power android 10
Device: Real me pro android 9

Version information

Ionic:

  Ionic CLI          : 5.4.15 (/usr/local/lib/node_modules/ionic)
  Ionic Framework    : ionic-angular 3.9.2
  @ionic/app-scripts : 3.2.2

Cordova:

  Cordova CLI       : 9.0.0 ([email protected])
  Cordova Platforms : android 8.1.0
  Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, (and 20 other plugins)

Utility:

  cordova-res (update available: 0.9.0) : 0.8.1
  native-run                            : 0.3.0

System:

  Android SDK Tools : 26.1.1 (/home/infini/Android/Sdk)
  NodeJS            : v12.13.1 (/usr/local/bin/node)
  npm               : 6.13.7
  OS                : Linux 4.15

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Recording Video

Creating a mobile interviews application and recording 30 minute videos ( 30 number of 1 minute clips using the limit and duration options of the media capture plugin)

     Need to upload video after every clip of recording to server.

Currently all video clips are returned in the MediaFile array after the recording is completed and not after each clip is recorded.
Please advise how to get the recorded file for each clip of recording, so that same can be uploaded to the server .Also the recording stops and same has to be started after each clip of recording.

captureAudio Does not work on oreo

App crash on oreo device when we give pemission for audio record
getting below issues
Audio No Activity found to handle Intent { act=android.provider.MediaStore.RECORD_SOUND }

[iOS] Don't save to photos

OS: iOS
Version: 12.1 (16B92)
Plugin Version: 3.0.2

Actual Behavior:
Captured photo is visible in Photos.

Expected Behavior:
Captured photo shouldn't be visible in Photos / CaptureOptions should allow to define whether saved to Photos or not.

Details:

  • Captured photo is stored in /mobile/Containers/Data/Application//tmp/photo_001.jpg by cordova-plugin-media-capture
  • Captured photo is then copied to /mobile/Containers/Data/Application//Library/NoCloud/xyz.jpg
  • Original photo is deleted from temp folder
  • Photo is still visible in Photos

Any ideas why it is behaving like this?

Thank you!

Hold to record - progress button

Feature Request

Motivation Behind Feature

Have set limits on video length recording is probably the case for 99.99% of us. Basically everyone except YouTube, because well, hosting ain't cheap.

It would be nice to have a multi functional record button to different the video functionality and correspond with a set video limit timer, ex. 30 seconds max.

Users are used to the round progress hold button in Snapchat, IG, etc. So it will be familiar that as the progress bar surrounding the circle comes close to eating it's tale, they are approaching the upper limit max of time they can record. There are various implementations of this 'hold to record' func (here's some old examples) and often just a button press is a camera snap, although many Cordova projects are using the camera plugin for that. Kind of a shame to use two plugins when this one could do a better job of both.

But ya, the record progress button has anyone done this yet?

Feature Description

image

error 20 in real device or emulator

Bug Report

Trow error 20

Problem

Api not available?

What is expected to happen?

expect to record audio

What does actually happen?

It trows an error , error 20

Information

cordova-plugin-media-capture 3.0.3 "Capture"
cordova 9

Command or Code

installed app-debug.apk

Environment, Platform, Device

Linux 8.04
Cordova 9

Version information

using VSCODE

Checklist

  • [x ] I searched for existing GitHub issues
  • [x ] I updated all Cordova tooling to most recent version
  • [x ] I included all the necessary information above
document.addEventListener("deviceready", onDeviceReady, false);

            function onDeviceReady (){

                const startButton = $('.startAudioRecorder');

                const stopButton = $('.stopAudioRecorder');

                startButton.on('click', recordAudio);

                function recordAudio() {

                    console.log('starting recording!');

                    var options = { limit: 1, duration: 10 };

                    navigator.device.capture.captureAudio(captureSuccess, captureError, options);

                    function captureSuccess(){
                        navigator.notification.alert('it did work..');

                    }

                    function captureError( error ){

                        navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');

                    }
                    stopButton.on('click', () => {

                        console.log('stoping reconrding');

                        /*
                        mediaRec.stopRecord();
                        mediaRec.release();
                        */
                        
                        stopButton.off('click');

                    });
                }

            }

Audio Capture NullPointerException audio record from sony

Good morning

All seems working with the samsung voice record, but when i use the audio record from sony i get this error:

11-15 11:20:02.150 13109-13170/com.horus.enterprise E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-2
    Process: com.horus.enterprise, PID: 13109
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference
        at org.apache.cordova.mediacapture.Capture.createMediaFile(Capture.java:454)
        at org.apache.cordova.mediacapture.Capture.onAudioActivityResult(Capture.java:369)
        at org.apache.cordova.mediacapture.Capture$1.run(Capture.java:326)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)

Im using

  • cordova 8.1.2 ([email protected])
  • android 7.1.2
  • cordova-plugin-camera 4.0.3 "Camera"
  • cordova-plugin-device 2.0.2 "Device"
  • cordova-plugin-file 6.0.1 "File"
  • cordova-plugin-media-capture 3.0.2 "Capture"
  • cordova-plugin-whitelist 1.3.3 "Whitelist"

Cordova record audio without using sound recorder

I'm using this plugin cordova-plugin-media-capture to record audio, when i tap start recording, the plugin launch sound recorder app to record the audio, but i don't want that, i want something like WhatsApp, to record the audio without leaving my app (meaning without using another app sound recorder).

This plugin is not working on the browsers(Android and iOS)

Bug Report

I used captureVideo function on the browsers of Android and iOS, but not working

Problem

I am getting the error code, 20.

What is expected to happen?

What does actually happen?

This plugin working on Android and iOS, but not browser.
I did the following;
ionic cordova run browser

Information

Command or Code

Environment, Platform, Device

Version information

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Image capture not working on Chrome browser on PC

Image capture isn't working on Chrome browser

Problem: The browser does not load the preview as expected

I tested this on android (works beautifully), Edge browser which also shows the preview div with the capture preview option.

What I get: Uncaught TypeError: Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided. is thrown in the console

Information

I'm trying to include the media capture plugin in a cordova app I've been working on. However I've failed to implement it in the browser for even simple applications.

I searched around in stackoverflow and answers indicate that createObjectURL is supposed to be passed either Blob, File or MediaSources and not raw data but I'm unsure what exactly I need to do to get the plugin working for chrome.

I'm using all latest versions of chrome, cordova.

The microphone covers the entire screen... I would like users to read short statements from the screen while the microphone is recording.. Is there a way to show text while the microphone is recording?

Issue Type

  • Bug Report
  • Feature Request
  • Support Question

Description

When you press the capture audio button it first asks for permission to use the microphone, then it opens the microphone in a full screen that covers the statements that I would like to be read, so the user can record but cannot see the statements they are supposed to read into the microphone.

Information

Command or Code

here is some code showing the issue, first the html showing 3 statements that I would like the user to record, and the capture audio button, and then the ts file:

here is the html

<ion-content>
  <ion-grid>
    <ion-row>
      <ion-col>
             <h1 class="ion-text-center">Record these statments</h1><br>
            <p class="ion-text-center">
              Go somewhere quiet.. and record these statements with as much enthusiasim as you can!
            </p>
            1. I am worthy of success. I am worthy of peace.<br><br>
            2. I accept myself as I am. I love myself as I am. I release all limiting thoughts. I honor myself always.<br><br>
            3. I am fearless. I am Powerful.<br><br>
           
                    <div class="ion-text-center">
                      <ion-button color="danger" (click)="captureAudio()">
                        <ion-icon name="mic"></ion-icon>Capture Audio</ion-button>
                    </div>
                  
            <ion-list style="background-color:#f0f0f0">
              <ion-radio-group value="1" required id="recordingradio">
              <ion-item *ngFor="let file of mediaFiles" tappable (click)="play(file)" text-wrap>
                My Recording
                <ion-radio id="recording" name="recording" required value="1"></ion-radio><br><br><br>
                <ion-button slot="end" color="success" href="/results" id="submit">
                  <ion-icon name="arrow-forward-circle" slot="start"></ion-icon>Continue</ion-button>
              </ion-item>
              </ion-radio-group>
            </ion-list>
      </ion-col>
    </ion-row>
  </ion-grid>
</ion-content>

Here is the .ts file

import { Component, OnInit, ViewChild } from '@angular/core';
import { NavController } from '@ionic/angular';
import { MediaCapture, MediaFile, CaptureError, CaptureVideoOptions } from '@ionic-native/media-capture/ngx';
import { Storage } from '@ionic/storage';
import { Media, MediaObject } from '@ionic-native/media/ngx';
import { File } from '@ionic-native/file/ngx';

const MEDIA_FILES_KEY = 'mediaFiles';

@Component({
  selector: 'app-confidence2',
  templateUrl: './confidence2.page.html',
  styleUrls: ['./confidence2.page.scss'],
})
export class Confidence2Page implements OnInit {
  mediaFiles = []

  constructor(public navCtrl: NavController, private mediaCapture: MediaCapture, private storage: Storage, private media: Media, private file: File) {}

  ionViewDidLoad() {
    this.storage.get(MEDIA_FILES_KEY).then(res => {
      this.mediaFiles = JSON.parse(res) || [];
    });
  }

  captureAudio(){
    this.mediaCapture.captureAudio().then(res => {
      this.storeMediaFiles(res);
    }, (err: CaptureError) => console.error(err));
  }
  
  play(myFile) {
    if (myFile.name.indexOf('wav.') > -1) {
      const audioFile: MediaObject = this.media.create(myFile.localURL);
      audioFile.play();
    } else {
      let path = this.file.dataDirectory + myFile.name;
      let url = path.replace(/file^\/\//, '');
      
    }
  }

  storeMediaFiles(files) {
    console.log('store: ', files);
    this.storage.get(MEDIA_FILES_KEY).then(res => {
      if (res) {
        let arr = JSON.parse(res);
        arr = arr.concat(files);
        this.storage.set(MEDIA_FILES_KEY, JSON.stringify(arr));
      } else {
        this.storage.set(MEDIA_FILES_KEY, JSON.stringify(files))
      }
      this.mediaFiles = this.mediaFiles.concat(files);
    })
  }
  ngOnInit() {
  }
}

Environment, Platform, Device

when emulating on all devices

Version information

ionic 6.6.0

plugins:
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 4.2.0 "cordova-plugin-ionic-webview"
cordova-plugin-media 5.0.3 "Media"
cordova-plugin-media-capture 3.0.3 "Capture"
cordova-plugin-nativeaudio 3.0.9 "Cordova Native Audio"
cordova-plugin-splashscreen 5.0.3 "Splashscreen"
cordova-plugin-statusbar 2.4.3 "StatusBar"
cordova-plugin-whitelist 1.3.4 "Whitelist"

Checklist

  • I searched for already existing GitHub issues about this
  • I updated all Cordova tooling to their most recent version
  • I included all the necessary information above

iOS 13 Audio Recording Modal Swipe Dismiss

Bug Report

Problem

It's now possible to dismiss the audio recording modal with a swipe on iOS 13. After you do that, the audio recorder keeps working, never calls any callback and won't let you start another recording.

What is expected to happen?

One should be able to interact with the recorder as they did before. Swiping should not be an issue.
I'd expect swiping away the modal to be the same as clicking Done.

What does actually happen?

When you swipe away the modal, it gets hidden but no recording callbacks get called and the recorder seems to linger in the background. This prevents attempts at trying a new recording.

Information

The new swipeable modals are an iOS 13 feature. There is a way to prevent swiping.

Command or Code

Call this in the js console:

navigator.device.capture.captureAudio();

After the recording modal opens, swipe it away.

Environment, Platform, Device

Tested with iPhone 6, iOS 13.

Version information

$ cordova -v
9.0.0 ([email protected])

$ cordova platform list
Installed platforms:
ios 5.0.1


Plugin version: 3.0.3

XCode version: 11.1



## Checklist
<!-- Please check the boxes by putting an x in the [ ] like so: [x] -->

- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above

Do you have to request permission manually on Android?

I am getting an error when I try to capture an image on android that is indicating that I do not have permission to write to external storage on an android 9.0 emulator. I do not see anything in the docs about needing to do this, and I do see that the permission has been added to the android manifest. Is this something that I need to request manually? Could the docs be updated to reflect this?

image capture not working in android

please refer to the image for stacktrace error
Screenshot_2019-11-20-00-15-37-780_com miui bugreport

Command or Code

Environment, Platform, Device

Version information

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Error while I add platform

Hey I'm using @ionic-native/video-capture-plus but it show me error while adding android platform :

Failed to install 'nl.x-services.plugins.videocaptureplus': Error: ENOENT: no such file or directory, open '/Users/bhuminbhandari/Desktop/Projects/ionic/casedetails/platforms/android/AndroidManifest.xml'

Configurable confirmation dialog for image capturing

Hello, is there any possibility to have a setting in CaptureImageOptions to not display the confirmation dialog after each picture you make? It is annoying to always have to click the 'confirm' button each time while doing 100 pictures at once.

Read the video file on android

Record video on android phone using the plugin
the fullpath is file:///storage/emulated/0/DCIM/Camera/VID_20190523_184820.mp4
How should I use cordova-plugin-file to read it ?

Here's my code:
I want to get the 'reader.result', thank you very much !

window.resolveLocalFileSystemURL(cordova.file.externalRootDirectory, function (dirEntry) {
dirEntry.getFile(_this.filename, { create: true, exclusive: false }, function (fileEntry) {
fileEntry.file(function (file) {
var reader = new FileReader()
reader.onloadend = function () {
console.log('Successful file read: ' + reader.result)
}
})
})

Supported Android apps for audio recording?

As far as i know, on android, only 2 apps support this pluggin (act = android.provider.MediaStore.RECORD_SOUND).

  • Audio Recorder from sony
  • Samsung Voice Recorder

There are any more app that can run this plugin properly?

Can't read video file on Android, error code 1

It works fine on iOS, but I get FileError with error code 1 on Android (tested 6.0, 7.0, 8.0).

I tried reading it with FileReader, as well as copying it with fileEntry.copyTo(), same error. Can't read it with XHR either.

The file exists, but can't seem to be read in any way by Cordova.

  • cordova version: 7.1.0
  • cordova-android version: 6.4.0
  • cordova-plugin-media-capture version: 3.0.2
  • cordova-plugin-file version: 6.0.1

Sample code below:

navigator.device.capture.captureVideo(
	function(mediaFiles){
		window.resolveLocalFileSystemURL(
			window.cordova.file.externalApplicationStorageDirectory,
			function(dirEntry){
				window.resolveLocalFileSystemURL(mediaFiles[0].fullPath,
					function(fileEntry){
						fileEntry.file(function(file){
							var reader = new FileReader();
							reader.onloadend = function(result) {
								console.log('Loaded');
							};
							reader.onerror = function(error) {
								console.error(error);
							};
							reader.readAsArrayBuffer(file);
						});
					},
					null
				);
			},
			null
		);
	}
);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.