javascript - Cordova - Capture video and retrieve base64 data -



javascript - Cordova - Capture video and retrieve base64 data -

i using phonegap record video , wanting save base64 data-encoded string. far have tried this..

function capturesuccess(mediafiles) { var i, path, len; path = mediafiles[0]; win(path); } function win(file) { var reader = new filereader(); reader.onloadend = function (evt) { console.log("read success"); console.log(evt.target.result); }; reader.readasdataurl(file); }; function captureerror(error) { navigator.notification.alert('error code: ' + error.code, null, 'capture error'); } function capturevideo() { navigator.device.capture.capturevideo(capturesuccess, captureerror, {limit: 1}); }

i have used readasdataurl specified in documentation. output of evt.target.result "data:video/mp4;base64," but there isn't encoded info after filetype.

is there else need add together in order total base64 info of video?

i struggling find can help me. help appreciated.

var b64toblobalt = function(datauri, contenttype) { var ab, bytestring, i, ia; bytestring = atob(datauri.split(',')[1]); ab = new arraybuffer(bytestring.length); ia = new uint8array(ab); = 0; while (i < bytestring.length) { ia[i] = bytestring.charcodeat(i); i++; } homecoming new blob([ab], { type: contenttype }); }; var path = mediafiles[0].fullpath; window.resolvelocalfilesystemurl(path, function(fileentry) { homecoming fileentry.file(function(data) { var reader = new filereader(); reader.onloadend = function(e) { var blob = b64toblobalt(e.target.result, 'video/mp4'); if (blob) { // whatever want blob }); } }; homecoming reader.readasdataurl(data); }); });

javascript cordova encoding base64

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -