Rodrigo Dias
Posts: 0
Joined: Fri May 01, 2015 7:08 am

Error using navigator.device.capture

I'm trying to implement use the Capture object to allow user to record audio in the app

I created a page with a button and in the click event I put the following javascript action:
######################################################
function captureSuccess(mediaFiles) {
alert('OK');
}

function captureError(error) {
var msg = 'An error occurred during capture: ' + error.code;
navigator.notification.alert(msg, null, 'Uh oh!');
}

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

captureAudio();
######################################################

When I click the button, running on the device, the following message is being shown: An error occurred during capture: 3

****

Additional information

  • In the Cordova Plugins tab of App Settings all the options are check

  • In the External Resources tab of App Settings the combo Libraries Version is v3.1

  • In the Android Permissions tab of the App Settings options RECORD_AUDIO and WRITE_EXTERNAL_STORAGE are checked

    I created the following function in a js file

    ##################################
    function onDeviceReady() {
    console.log(navigator.device.capture);
    }
    ##################################

    And put the following code in the LOAD event of the page that contains the button

    document.addEventListener("deviceready", onDeviceReady, false);

    What am I doing wrong?

    Thanks in advance...

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Error using navigator.device.capture

Hello,

This is something outside the scope of standard Appery.io platform support. You may consider purchasing Advisory Pack to get more in-depth help on this question. Here is more information about Advisory Pack (http://appery.io/services/#Advisory_Pack).

Rodrigo Dias
Posts: 0
Joined: Fri May 01, 2015 7:08 am

Error using navigator.device.capture

Hi Kulibaba

Thanks for your reply.

Could you please help me just to get the object navigator.device initialized avoiding the following error message being shown in the debugger?

"Uncaught TypeError: Cannot read property 'capture' of undefined"

It occurs when I try to access the function "navigator.device.capture.captureAudio"

Thanks for your assistance.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Error using navigator.device.capture

Hi Rodrigo,

Is this object is a part of Appery.io platform? Where did you get this object?

We would love to help you, but debugging custom JS code is outside the scope of our standard support. https://devcenter.appery.io/support-p...

Rodrigo Dias
Posts: 0
Joined: Fri May 01, 2015 7:08 am

Error using navigator.device.capture

Hi Illya,

This is an instance of "Cordova Media Capture Plugin" included in the Appery Platform.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Error using navigator.device.capture

Thanks for clarification. Please check if this plugin is enabled in the App Settings Cordova plugins for your app.

Rodrigo Dias
Posts: 0
Joined: Fri May 01, 2015 7:08 am

Error using navigator.device.capture

Yes, it is.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

Error using navigator.device.capture

You will need to add this JS code on the Device ready event before invoking object .capture in your app:

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

For invoking .capture object in the app it is better to use call-back functions like shown in plugin documentation: https://github.com/apache/cordova-plu...

Return to “Issues”