Page 1 of 1

Error using navigator.device.capture

Posted: Fri Apr 01, 2016 3:57 am
by Rodrigo Dias

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...


Error using navigator.device.capture

Posted: Fri Apr 01, 2016 7:30 am
by Serhii Kulibaba

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).


Error using navigator.device.capture

Posted: Fri Apr 01, 2016 12:01 pm
by Rodrigo Dias

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.


Error using navigator.device.capture

Posted: Fri Apr 01, 2016 3:50 pm
by Illya Stepanov

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...


Error using navigator.device.capture

Posted: Fri Apr 01, 2016 5:27 pm
by Rodrigo Dias

Hi Illya,

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


Error using navigator.device.capture

Posted: Fri Apr 01, 2016 7:30 pm
by Illya Stepanov

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


Error using navigator.device.capture

Posted: Fri Apr 01, 2016 8:51 pm
by Rodrigo Dias

Yes, it is.


Error using navigator.device.capture

Posted: Sat Apr 02, 2016 2:16 pm
by Illya Stepanov

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...