iphone - 如何将流媒体视频存储在 iOS 的资源文件夹中?

标签 iphone ios uiwebview video-streaming resourcebundle

如果我直截了当,那么我的问题是,我想制作一个 Web View ,它将在其中加载视频,当流开始时,我想将该视频数据下载/存储在应用程序的资源文件夹中。如何我可以这样做吗?

请有人帮助我。

BR

阿门

最佳答案

在运行时你不能将视频保存到资源文件夹,但你可以将文件保存到 NSDocuments 并使用 NSFileManagers 检索它们。通过此链接进行 http://www.techotopia.com/index.php/Working_with_Files_on_the_iPhone

尝试使用此代码保存文件

 NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); 
 NSString *documentsDirectory = [paths objectAtIndex:0];                    
 NSString *filePath = [NSString stringWithFormat:@"%@/filename.MP4",documentsDirectory];
 NSData*   videoData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"your Url"]];
 [[NSFileManager defaultManager] createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil];
 [filemanager createFileAtPath:filePath contents:videoData attributes:nil];

检索:

 NSArray *paths =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); 
 NSString *documentsDirectory = [paths objectAtIndex:0];                    
 NSString *filePath = [NSString stringWithFormat:@"%@/filename.MP4",documentsDirectory];
    BOOL exists = [fm fileExistsAtPath:newDirectory isDirectory:&isDir];
    if (exists) {
     //Play Video with contents of file path. 

      }

关于iphone - 如何将流媒体视频存储在 iOS 的资源文件夹中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14230005/

相关文章:

iphone - 如何-performSelector :withObject:afterDelay: work?

iPhone崩溃记者

iphone - UILocalNotification 多次触发

ios - 无法在 iPod Touch 中部署 Xamarin 项目

iphone - UIWebView 中横向模式的 Youtube 视频

swift - 调整 ipad swift 3 的 WebView 大小

iphone - 预编译 prefix.pch 时出现奇怪的编译器警告

ios - 有没有办法在不安装容器应用程序的情况下安装 iOS 扩展?

ios - 无法隐藏 UIButton?