首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Exc_Bad_access in AVAssetReader

Exc_Bad_access in AVAssetReader
EN

Stack Overflow用户
提问于 2015-01-20 12:20:35
回答 1查看 495关注 0票数 1

在使用Exc_bad_Access读取文件时,我得到了AVAssetReader异常。文件位于文档目录中,采用m4a格式。这是我正在使用的代码。不知道哪里弄错了:

代码语言:javascript
复制
 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filepath = [documentsDirectory stringByAppendingPathComponent:@"My_Recording2.m4a"];

NSURL *newURL=[NSURL URLWithString:filepath];

if ([[NSFileManager defaultManager] fileExistsAtPath:newURL.absoluteString])
{
    NSLog(@"File exists");
}

AVURLAsset *asset = [AVURLAsset URLAssetWithURL:newURL options:nil];
NSError *assetError;

if(asset)
    NSLog(@"all ok");

self.assetReader = [AVAssetReader assetReaderWithAsset:asset error:&assetError];

我在最后一行得到了异常。

代码语言:javascript
复制
self.assetReader = [AVAssetReader assetReaderWithAsset:asset error:&assetError];
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-20 13:20:00

我认为你的NSURL URLWithString:filepath是不对的。你能用fileURLWithPath方法试试吗?希望这能解决你的问题。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28045273

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档