How to save captured video/audio in IOS photo Albums

  • 1
  • Question
  • Updated 4 years ago
Hi
Blow Mentioned is my code ,i am able to capture video but not able to save it to a specific path .Can anybody help for this issue.

this option {destinationType : Camera.DestinationType.FILE_URI,saveToPhotoAlbum:true } works for images but not for videos

function handler_actionBtn1_onClick(mouseev){
if(!app.isNativeApp()) {
app.alert('This App is running as a Web App, so device functions are not accessible');
return;
}

var captureSuccess = function(mediaFiles) {
var i, path, len;
for (i = 0, len = mediaFiles.length; i < len; i += 1) {
var data = [
{type: mediaFiles[i].type, src: mediaFiles[i].fullPath}
];

var map = {type:"type", src:"src"};

app.populateWidget("HTML5Video", data, map);

}

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

// navigator.device.capture.captureVideo(captureSuccess, captureError);

navigator.device.capture.captureVideo(captureSuccess, captureError, {destinationType : Camera.DestinationType.FILE_URI,saveToPhotoAlbum:true });
}
Photo of NICK

NICK

  • 6 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Nick
Welcome to Phonegap.

Since this is your first post, please answer the following question.
- Is this your first hybrid App?
- What is your target device/platform and their target versions? Android 4,5,6? iOS 7,8,9?
- What platform are you developing on? Windows, MacOS, Linux?
- Are you using CLI, SDK or Build? Please do not assume the answer, please read the link.

Thanks
Jesse
Photo of NICK

NICK

  • 6 Posts
  • 0 Reply Likes
Thank you Jesse for the Quick reply

--Yes this my first hybrid App.

--Basically in Android i am able to view my audio/video in file manager section just have problem with my ipad as its getting stored in private folder, location is as follows
(/private/var/mobile/Containers/Data/Application/2183897E-3660-4145-A822-76F5B763E48D/tmp/capture-T0x17e7cae0.tmp.avqBi2/capturedvideo.MOV)
so i am not able to view it .I want to move my captured media in Photo Album section in my ipad so that i can view these media's without using my app too.
As i have mentioned in my earlier post that i am able to store my capture images in photo album section just facing problem with audio/video

--my iOS version is 9.2.1

--i am working on windows platform

this is the phone gap plugin i am using currently in my app

(org.apache.cordova.media-capture" version="0.3.3")
but using this plugin and above mentioned code which is on the top of the previous post i am not able to achieve my task

--i read somewhere that this plugin can solve this problem

(org.apache.cordova.core.media-capture" version="3.0")
but while using this plugin in my app i am getting an err (undefined is not any object (evaluating 'navigator.device.capture')) basically its not supporting this plugin

and i have tried this plugin also

("org.apache.cordova.core.media-capture" version="3.0")
but while making a phonegap build i am getting an err (org.apache.cordova.core.media-capture @3.0 is not supported ) for reference PFA IMAGE
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Nick
Please answer the remaining questions.

NOTE: your answers are confusing. You say "Basically in Android", then in that same paragraph you say "I want to move my captured media in Photo Album section in my ipad"

Since this is your first post, please answer the following question.
- Is this your first hybrid App?
- What is your target device/platform and their target versions? Android 4,5,6? iOS 7,8,9?
- What platform are you developing on? Windows, MacOS, Linux?
- Are you using CLI, SDK or Build? Please do not assume the answer, please read the link.

Thanks
Jesse
Photo of NICK

NICK

  • 6 Posts
  • 0 Reply Likes
@jesse
ok to make my point more clear

target device ipad Air ios version 9.2.1

i am using Build

Hope i made my point clear this time

Thnx
Nick
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@NICK,
Okay. I am going to be blunt. Your biggest issues is not following instruction. (No insult intended.) Putting aside the timely responses you have made, a blaring 2x4 was available.

Your Fix
On the image you posted, in the red banner - which is on the top and the bottom, it says:


plugin unsupported: org.apached.cordova.code.media-capture @3.0


This means the plugin you are using is not supported at 3.0.

Documentation for the plugins are here:
http://docs.build.phonegap.com/en_US/configuring_plugins.md.html#Plugins

The core plugins are listed here:
https://build.phonegap.com/plugins/core

On the left of that page for your plugin, it says the current version is 0.3.6

FWIW, this FAQ should help. I recommend reading the bold sentences.

Top Mistakes by Developers new to Cordova/Phonegap

Best of Luck
Jesse
Photo of NICK

NICK

  • 6 Posts
  • 0 Reply Likes
@jesse

Thank you for your valuable response
Firstly i would like to apologize if you find my response blaring ,It wasn't meant to be in that way

Regarding the image i shared
while searching on web i found one of the post mentioning that for iOS devices this plugin (org.apached.cordova.code.media-capture @3.0 ) can be used for storing and capturing videos in photo album section , that is why i shared my findings with you .
As in the image err is quite clear as it says plugin unsupported: org.apached.cordova.code.media-capture @3.0 thus i searched on web for the latest version and i found current version is 0.3.6 as you have also mentioned in your response .

i have tried using the latest latest version @0.3.6 too but still the captured medias are getting saved in the private folder which i can't access in ipad without using my application. My target is to just stored my captured media in desired location so that i can view it without using my app

Thanks
Nick
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes

Thank you for your valuable response
Firstly i would like to apologize if you find my response blaring ,It wasn't meant to be in that way


@Nick, No problem.


i have tried using the latest latest version @0.3.6 too but still the captured medias are getting saved in the private folder which i can't access in ipad without using my application. My target is to just stored my captured media in desired location so that i can view it without using my app


Okay you have two (2) separate issues.

1. Is the media being captured.
2. Is the media being stored.

You should treat that as two (2) separate issues. Trying to do both at the same time can be hazardous. Which would you like to try first?

Jesse
Photo of NICK

NICK

  • 6 Posts
  • 0 Reply Likes
Thank you jesse for your reply
Sorry for the late reply as i was having some bandwidth issue.



1. yes i can capture media successfully.
2. yes i can store media successfully in my ipad

i can view and play my captured video through my app. if i will close my app and try to search my video in ipad ,i can't find it as by default captured video is getting saved in private temp folder .

for your reference i am mentioning the url below where the captured video is getting stored
URL
(/private/var/mobile/Containers/Data/Application/2183897E-3660-4145-A822-76F5B763E48D/tmp/capture-T0x17e7cae0.tmp.avqBi2/capturedvideo.MOV)

As above mentioned location we can't see in the ipad

so can you please guide me if i can move my captured video from one location to desired location
or
if this is possible. At the time of capturing my video i can assign my desired path so that video can be save in the assigned location rather then getting save in default .

i have tried File api of phonegap but didn't got any luck

thanks
nick
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@Nick,
okay. if you can capture media and you can store it, then I'm not sure what the problem is.

i can view and play my captured video through my app. if i will close my app and try to search my video in ipad ,i can't find it as by default captured video is getting saved in private temp folder.

That is correct. By default, stores things in the temp folder. If you want to have the media available for use later, then you need to make a copy. This is in the documentation for the File plugin. Did you read it?

I know the documentation can be confusing. So, try to find the part where you copy the file to a new location.

Jesse
Photo of NICK

NICK

  • 6 Posts
  • 0 Reply Likes
Hi jesse

As i have mentioned in my previous post



and you are also suggesting


i am not getting an luck

if have any suggestion please provide

here is what i am using

function success(entry) {
console.log("New Path: " + entry.fullPath);
}

function fail(error) {
alert(error.code);
}

function moveDir(entry) {
var parent = document.getElementById('parent').value,
parentName = parent.substring(parent.lastIndexOf('/')+1),
newName = document.getElementById('newName').value,
parentEntry = new DirectoryEntry(parentName, parent);

// move the directory to a new directory and rename it
entry.moveTo(saveToPhotoAlbum, newName, success, fail);
}
Photo of JesseMonroy650 (Volunteer)

JesseMonroy650 (Volunteer), Champion

  • 3325 Posts
  • 122 Reply Likes
@NICK,
that's not the entire code for even accessing a file. Where is you code? Can you post it to a public website (github, pastebin,etc)?

FWIW: Here is my test code on cordova-plugin-file. The package is called cordova-storage-file

Let me know
Jesse
Photo of Ben McMaster

Ben McMaster

  • 66 Posts
  • 1 Reply Like
Anyone find a solution to this? I would love to be able to save videos from captureVideo() to iOS camera roll...

Seems like all you do is comment out a few lines in the plugin...

http://stackoverflow.com/questions/25...

Or is there an easy way to move the file to camera roll...