Thursday 15 September 2011

javascript - Phonegap 3.5 fetching audio / video files from external sd card Android -



javascript - Phonegap 3.5 fetching audio / video files from external sd card Android -

currently not able fetch video (.mp4) , sound (.wav) files external sd card, want fetch files , convert them base64 , send them server.

here code

window.requestfilesystem(localfilesystem.persistent, 0, function(filesystem) { // filesystem's root -> file:///storage/emulated/0/ var url = "cdvfile://localhost/root/storage/extsdcard/dcim/camera/20141018_143740.mp4"; window.resolvelocalfilesystemurl(url, function(fileobj) { var fullpath = fileobj.fullpath; // fullpath -> file:/storage/extsdcard/dcim/camera/20141018_143740.mp4 filesystem.root.getfile(fullpath, null, function(fileentry) { fileentry.file(function(file) { //.. filereader function convert file base64 reader.readasdataurl(file) },errorfunc); },errorfunc); },errorfunc); },errorfunc);

now problem not able .mp4 file i.e. filesystem.root.getfile giving me error error code 1 i.e. file not found

after checking few stack overflow questions , http://rickluna.com/wp/2014/01/accessing-external-storage-in-android-phonegap-3-3/ blog think problem lies in "root"

i.e. filesystem obj (success callback of requestfilesystem method) looks this:

filesystem: filesystem fullpath: "/" isdirectory: true isfile: false name: "" nativeurl: "file:///storage/emulated/0/" __proto__: utils.extend.f

so possible alter root? i.e. file:///storage/emulated/0/ file:///storage/ can phone call getfile , pass absolute url i.e. /extsdcard/dcim when( file:///storage/) becomes root

i tried changing root i.e.

filesystem.root.fullpath = 'file:///storage/';

even tried alter nativeurl property of filesystem object it's not working

ps. solution given in blog hasn't worked me

ps ps. same code working fine when absolute url is: file:///storage/emulated/0/mrs/filename.txt , passing relative url in function i.e. filesystem.root.getfile("mrs/filename.txt",...)

javascript html5 cordova

No comments:

Post a Comment