0

I am using PhoneGap Build to build an iOS application and using weinre to debug. So far so good.

I am trying to use the media-capture and file APIs to capture a video and get its base64 representation. I can get the video recorder to open, take a video, and return. The problem is I can not get resolveLocalFileSystemURL to open the path. Every time it returns with an error code of 5 to which I can not seem to find a single answer as to what that means. This is running on a real device so it is not a problem with the emulator.

I have checked every post I could find via Google. Have been sratching my head for days on this one. Everyone who proposed an answer was either using Xcode-- as opposed to Build-- or the answer simply did not work for me.

Below is my code. Below that is the console output.

elements["media_video"].onclick = function(event) {
    navigator.device.capture.captureVideo(
        function(files) {
            for ( var i = 0 ; i < files.length ; ++i ) {
                var file = files[i];

                var name = file.name;
                var path = file.fullPath;
                var type = file.type;
                var lastModifiedDate = file.lastModifiedDate;
                var size = file.size;

                console.log(0, name, path, type, lastModifiedDate, size);

                var reader = new FileReader();
                reader.onloadend = function(event) {
                    console.log(3, event.target.result);
                };

                window.resolveLocalFileSystemURL(
                    path,
                    function(entry) {
                        console.log(1, entry.name);

                        reader.readAsDataURL(entry);
                        // send base64 data to server
                    },
                    function(error) {
                        console.log(2, error.code);
                    }
                );
            }
        },
        function(error) {},
        {
            limit:  1
        }
    );
};

0 "capturedvideo.MOV" "/private/var/mobile/Applications/[application uuid]/tmp/capture/capturedvideo.MOV" "video/quicktime" 1409866447000 205788
2 5

Edited by nickwebha: Added some context.

1
Contributor
1
Reply
10
Views
3 Years
Discussion Span
Last Post by nickwebha
1

Figured it out.

For anyone looking resolveLocalFileSystemURL() expects a valid URL (file:// required). Also you must strip off /private for... some reason (ask Apple).

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.