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

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

问题描述

我有一个应用程序,其中他们的按钮命名为视频。当用户点击按钮一个新的视图打开包括4其他按钮,即拍摄视频和浏览视频。当他点击拍摄视频相机打开允许他拍摄视频,视频被插入视图。这一切都已经完成。但是他们是一个问题,当用户已经拍摄视频和视频插入在视图是一个按钮的名为添加的视图允许将视频插入sqlite数据库。我有一个问题,如何绑定视频和如何插入捕获的视频到sqlite数据库。任何人都帮助我解决这个问题。谢谢

i have an application in which their 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.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 have been done .but their is a problem when the user has taken the video and the video gets inserted on the view the is a button the view named add which when 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.Please anybody help me in solving this problem.Thanks

推荐答案

尝试将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)使用此唯一名称保存文件。现在保存SQLite DB中的 uniqueId

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 ,尝试从它构造文件路径, p>

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天全站免登陆