在使用Exc_bad_Access读取文件时,我得到了AVAssetReader异常。文件位于文档目录中,采用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];发布于 2015-01-20 13:20:00
我认为你的NSURL URLWithString:filepath是不对的。你能用fileURLWithPath方法试试吗?希望这能解决你的问题。
https://stackoverflow.com/questions/28045273
复制相似问题