Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File not Found but ... file exists #11

Closed
CostanzoPablo opened this issue Feb 28, 2015 · 5 comments
Closed

File not Found but ... file exists #11

CostanzoPablo opened this issue Feb 28, 2015 · 5 comments

Comments

@CostanzoPablo
Copy link

Cordova + platform Android

Line Code:
fileUri: currentEntries[file].fullPath

Error:
java.net.MalformedURLException: Protocol not found: /mt4p/VID_20150208_175451753.mp4


Edit Code:
fileUri: 'file://' + currentEntries[file].fullPath

Error:
java.io.FileNotFoundException

The file exist and doing console.log(currentEntries[file].fullPath); it says /mt4p/VID_20150208_175451753.mp4

Full code:

function getFileSystem(){
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
function(fileSystem){ // success get file system
root = fileSystem.root;
listDir(root);
}, function(evt){ // error get file system
console.log("File System Error: "+evt.target.error.code);
}
);
}

function listDir(directoryEntry){
$('#files').empty();
$('#files').append('

BACK
');
if( !directoryEntry.isDirectory ) console.log('listDir incorrect type');

currentDir = directoryEntry; // set current directory
directoryEntry.getParent(function(par){ // success get parent
    parentDir = par; // set parent directory
    if( (parentDir.name == 'sdcard' && currentDir.name != 'sdcard') || parentDir.name != 'sdcard' ) $('#backBtn').show();
}, function(error){ // error get parent
    console.log('Get parent error: '+error.code);
});

var directoryReader = directoryEntry.createReader();
directoryReader.readEntries(function(entries){
    currentEntries = entries;
    for(var i=0; i<entries.length; ++i){ // show directories
        //var entry = sortedArr[i];
        //var blockLetter = uiBlock[i%4];
        //console.log(entry.name);
        if( entries[i].isDirectory ){
            $('#files').append('<div class="folder" onclick="openFolder('+ i + ');">' + entries[i].name + '</div>');
        }else{
            $('#files').append('<div class="file" onclick="openFile('+ i + ');">' + entries[i].name + '</div>');
        }

    }

}, function(error){
    console.log('listDir readEntries error: '+error.code);
});

}

function openFolder(folder){
currentDir.getDirectory(currentEntries[folder].name, {create:false},
function(dir){ // success find directory
listDir(dir);
},
function(error){ // error find directory
console.log('Unable to find directory: '+error.code);
}
);
}

function openFile(file){
console.log(currentEntries[file].fullPath);
VideoEditor.transcodeVideo(
videoSuccess, // success cb
videoError, // error cb
{
fileUri: 'file://' + currentEntries[file].fullPath, // the path to the video on the device
outputFileName: 'file://mt4p/pepito.mp4', // the file name for the transcoded video
quality: VideoEditorOptions.Quality.MEDIUM_QUALITY,
outputFileType: VideoEditorOptions.OutputFileType.MPEG4,
optimizeForNetworkUse: VideoEditorOptions.OptimizeForNetworkUse.YES,
duration: 20 // optional, specify duration in seconds from start of video
}
);
}

AndroidManifest.xml


cordova plugins list
org.apache.cordova.file 1.3.3 "File"
org.apache.cordova.videoeditor 0.0.2 "VideoEditor"

@CostanzoPablo
Copy link
Author

My mistake. Putting this stop giving this error.

fileUri: 'file://mnt/sdcard/1/1.mp4',

Now I have this other: "an error ocurred during transcoding"

@CostanzoPablo
Copy link
Author

My mistake. outputFileName: 'gg.mp4',
Only name, no path. Like the comment. // the file name for the transcoded video

@razwasserstein
Copy link

Hi!

Happened to me too..
If I use the resolveLocalFileSystemURI, it returns: "an error ocurred during transcoding".
And if I use the fullPath it returns: "java.net.MalformedURLException: Protocol not found:"..

What can I do?

Android 4.2.2.

@CostanzoPablo
Copy link
Author

No you got to use the resolveLocalFileSystemURI. Just put ...

The fullPath for the origin
fileURI: 'file: //mnt/sdcard/123456.mp4'

And only the name of the output (without fulPath)
OutputFileName 'gg.mp4'

@dahico-dk
Copy link

instructions unclear. Please enlighten me and put some working code here.

what is the correct path for a file? //mnt/sdcard/123456.mp4' is not clear.

I am using ionic and I have a file at file:///android_asset/www/img/smp12.mp4. And another one in the devices sd card root directory.

I tried many options but all of them returned file not found exception. Can you elloborate the your file path solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants