Getting the videos from iPhone in our app
How can we get the video which are stored in the iphone library and Can we save that in our local database in our app and then we will d开发者_StackOverflow社区elete the video from the iPhone Library, so that the video cannot be able to access in the iPhone library, but it can be used in the app.
NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
NSURL *url = [info objectForKey:UIImagePickerControllerMediaURL];
NSString * documentsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSString * fetchPath = [documentsDirectory stringByAppendingPathComponent:@"TestDemo"];
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager fileExistsAtPath:fetchPath] == YES) {
[fileManager removeItemAtPath:fetchPath error:nil];
}
NSError * error = nil;
if (Videourl == nil) {
return;
}
[appDelegateIphone showLoadingViewforLandScapeRight];
[[NSFileManager defaultManager] copyItemAtURL:url
toURL:[NSURL fileURLWithPath:fetchPath]
error:&error];
You can use UIImagePickerController
for retrieving images and videos from the iPhone Library.
You are not able to delete any image or videos from the iPhone library.
Use the UIImagePickerController
class, and set the sourceType to be UIImagePickerControllerSourceTypePhotoLibrary
(this will present the user with the dialogue to choose an item from their iPhone library).
The delegate method didFinishPickingMediaWithInfo
will then return a URL to the video the user has selected.
You cannot delete a video stored in the iPhone library. However, you could use the UIImagePickerController
to prompt the user to record a video. You can then save this video to the file area of your app. By default it will not be saved to the iPhone library.
Check out the Apple documentation for more info.
Hope that helps.
精彩评论