Capturing video in Android in the background on a phone with a minimal recording screen

I tried the following code. I want to record a video in the background and save it to an SD card. I do not want to do manual recording and stop recording. Is it possible to record video with or without API in PhoneGap. I want to record a video in the background

<html> <head> <title>Capture Video</title> <script type="text/javascript" charset="utf-8" src="js/cordova.js"></script> <script type="text/javascript" charset="utf-8" src="js/json2.js"></script> <script type="text/javascript" charset="utf-8"> // A button will call this function function captureVideo() { // Launch device video recording application, // allowing user to capture up to 3 video clips alert("captureVideo"); var options = { limit : 2, duration : 10 }; navigator.device.capture.captureVideo(captureSuccess, captureError, options); } // Called when capture operation is finished function captureSuccess( mediaFiles) { alert("captureSuccess "); var i, len; alert(mediaFiles.length); for (i = 0, len = mediaFiles.length; i < len; i += 1) { uploadFile(mediaFiles[i]); } } // Called if something bad happens. function captureError(error) { var msg = 'An error occurred during capture: ' + error.code; navigator.notification.alert(msg, null, 'Uh oh!'); } // Upload files to server function uploadFile(mediaFile) { alert("uploadFile"); var ft = new FileTransfer(), path = mediaFile.fullPath, name = mediaFile.name; alert("path:" + path); alert("name:" + name); ft.upload(path, "http://my.domain.com/upload.php", function(result) { console.log('Upload success: ' + result.responseCode); console.log(result.bytesSent + ' bytes sent'); }, function(error) { console.log('Error uploading file ' + path + ': ' + error.code); }, { fileName : name }); } </script> </head> <body> <button onclick="captureVideo();">Capture Video</button> <br> </body> </html> 
+8
javascript jquery-mobile cordova video-capture
source share
2 answers

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

function start_here(){captureVideo();}
The function is called when the application and video are launched automatically.
and after sending, start recording again ...

  function uploadFile(mediaFile) { alert("uploadFile"); var ft = new FileTransfer(), path = mediaFile.fullPath, name = mediaFile.name; alert("path:" + path); alert("name:" + name); ft.upload(path, "http://my.domain.com/upload.php", function(result) { console.log('Upload success: ' + result.responseCode); console.log(result.bytesSent + ' bytes sent'); }, function(error) { console.log('Error uploading file ' + path + ': ' + error.code); }, { fileName : name }); start_here; /*just call the instance. here is the change*/ } 
0
source share

Now you can record video with a minimal application or even when the screen is disconnected cordova \ phonegap \ ionic plugin

This is a plug, but the main repo cannot record video "in the background" (despite the name).

When it starts, it automatically chooses where to store the video, according to the size of free space on the SD and internal drive.

 cordova plugin add cordova-backgroundvideo var fileName = new Date().getTime() + ''; cordova.plugins.backgroundvideo.start(fileName, 'back', true, null, null); cordova.plugins.backgroundvideo.stop(function (filePath) { alert(filePath); }, function (error) { alert('Error ' + JSON.stringify(error)); } ); 
0
source share

All Articles