如何将相机拍摄的视频保存到iPhone的SQLite数据库中? [英] How to save a video taken from camera into SQLite database in iPhone?

查看:115
本文介绍了如何将相机拍摄的视频保存到iPhone的SQLite数据库中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,其中有一个名为video的按钮。当用户单击按钮时,将打开一个新视图,其中包含其他4个按钮,即拍摄视频和浏览视频。

I have an application in which there is button named video. When a user clicks on the button a new view opens which consists of 4 other buttons namely take video and browse for video.

当他单击拍摄视频时,摄像机即会打开允许他拍摄视频并将视频插入到视图中。所有这些都已经完成,但是当用户拍摄视频并且视频被插入视图时,会出现问题。在视图上有一个名为add的按钮,允许将视频插入SQLite数据库。

When he clicks on take video the camera opens which allows him to take video and the video gets inserted on the view. This all has been done, but there is a problem when the user has taken the video and the video gets inserted on the view. There is a button on the view named add which allows to insert the video into the SQLite database.

我在如何绑定视频以及如何插入视频方面遇到问题

I am having a problem on how to bind a video and how to insert the captured video into SQLite database.

推荐答案

试图将Roberto的建议放入代码中:

Trying to put Roberto's suggestion in code:

1)生成一个唯一的ID(通过时间戳/哈希/ CFUUIDCreate ...生成)。

1) generate a unique Id (generated by time stamp/ hash / CFUUIDCreate ...) .

CFStringRef uStr =  CFUUIDCreateString(kCFAllocatorDefault,CFUUIDCreate(kCFAllocatorDefault));  
NSString *uniqueId = [[NSString alloc] initWithString:uStr];  

2)使用此唯一名称保存文件。现在,将 uniqueId 保存在SQLite数据库中。

2) save the file in with this unique name. Now save the uniqueId in SQLite DB.

NSString *docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];  
NSString *filePath = [docsDir sstringByAppendingPathComponent:uniqueId];  
NSFileManager *fManager = [NSFileManager defaultManager];   
if (![fManager fileExistsAtPath:fileDirPath])   
{   
    // save the file   
}

3)为了获取视频,请从 uniqueId 尝试用

3) In order to get the video, from the uniqueId, try to construct the file path from it as,

NSString *docsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *filePath = [docsDir sstringByAppendingPathComponent:uniqueId];
NSFileManager *fManager = [NSFileManager defaultManager];  
if ([fManager fileExistsAtPath:fileDirPath])   
{   
    // access the file   
}

这篇关于如何将相机拍摄的视频保存到iPhone的SQLite数据库中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆