0

I am trying to capture video in android app using phonegap, but facing problem

TypeError: Result of expression 'navigator.device.capture.captureVideo' [undefined] is not a function.

Here bellow is my code
I included following in head

<script type="text/javascript" src="js/phonegap-1.2.0.js"></script>
<script src="js/jquery-1.6.4.min.js"></script>

<script type="text/javascript">
 function recordVideo(){
 var capture = navigator.device.capture;
 var options1 = { limit: 1 };
navigator.device.capture.captureVideo(captureSuccess, captureError, options1);
alert("Record");
 }

function captureSuccess(mediaFiles) {
    var i, len;
    for (i = 0, len = mediaFiles.length; i < len; i += 1) {

       alert(mediaFiles[i].name);
    }       
}

function captureError(error) {
    var msg = 'An error occurred during capture: ' + error.code;

    alert(msg);
}
</script>

And code for capturing on a button click <a href="javascript:void(0);" onClick="recordVideo();">Capture Video</a>

But I getting this error on console

TypeError: Result of expression 'navigator.device.capture.captureVideo' [undefined] is not a function.

Please help me.

Thanks in advance.

Timir

Serge P
  • 1,173
  • 3
  • 25
  • 39
Timir Maji
  • 19
  • 3

1 Answers1

1

You should add the required plugin (https://github.com/apache/cordova-plugin-media-capture/blob/master/doc/index.md)

If you are using intel xdk go to project -> plugins and permissions

Paizo
  • 3,986
  • 30
  • 45