NICK7637433
Posts: 0
Joined: Mon Jul 13, 2015 10:00 am

While capturing the video how to get its base64 string

Hi,
I am able to capture audio and video by using this code
// capture callback
var captureSuccess = function(mediaFiles) {
var i, path, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
path = mediaFiles.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});

Know my requirement is i want to store that audio and video which i have captured in ms sql database so that i can retrieve that video/audio anywhere and can play in any device . Can anybody tell me how to get the base64 of audio and video .

NICK7637433
Posts: 0
Joined: Mon Jul 13, 2015 10:00 am

While capturing the video how to get its base64 string

Hi Evgene,
Thanx for your quick reply . Above link are not providing me any solution for my case . Here is the code for image which works
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
destinationType: Camera.DestinationType.DATA_URL
});

function onSuccess(imageData) {
var image = document.getElementById('myImage');
image.src = "data:image/jpeg;base64," + imageData;
}

function onFail(message) {
alert('Failed because: ' + message);
}

in this we are able to get the base64 as we click the image . i m searching for same scenario for audio and video if it is possible ?....

This is what i have tried :

function captureSuccess(mediaFiles) {
var i, len,path;
path = mediaFiles[0];
win(path);
var data = [
{type: mediaFiles[0].type, src: mediaFiles[0].fullPath}
];
var map = {type:"type", src:"src"};
app.populateWidget("HTML5Video", data, map);

}

function win(path) {

Code: Select all

 var reader = new FileReader(); 
 reader.onloadend = function (evt) { 
     console.log("read success"); 
 app.showMessage(evt.target.result); 
 }; 
 reader.readAsDataURL(path);  

};

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

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

output in alert is :- data:video/quicktime;base64,

i m not able to the get base64 string , can you point out where is the mistake
or if you know any alternative for achieving this ( i want to store video/audio in database in any format so that i can retrieve it and can play in any other devices )
please share

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

While capturing the video how to get its base64 string

Hello Nick,

This should be possible, but we do not have ready example of code for this case, please search online for solutions, e.g. http://stackoverflow.com/questions/24...

Return to “Issues”