【发布时间】:2015-01-20 12:20:35
【问题描述】:
我在使用 AVAssetReader 读取文件时遇到 Exc_bad_Access 异常。 该文件位于文档目录中,格式为 m4a。这是我正在使用的代码。无法弄清楚我哪里弄错了:
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];
我在最后一行遇到异常,即
self.assetReader = [AVAssetReader assetReaderWithAsset:asset error:&assetError];
【问题讨论】:
-
使用 AVAsset assetWithURL: 只是为了尝试 AVURLAsset 可能是用于 web 内容。您的assetReader 属性是否设置为strong?
-
是的assetReader 属性很强大。我尝试使用assetWithURL 仍然是相同的结果。
标签: ios objective-c iphone avasset avassetreader