【发布时间】:2014-06-08 00:43:14
【问题描述】:
我正在尝试从手机上的本地文档中获取 mp3。但我无法让它工作。
如果我像这样直接将 mp3 添加到项目中,它可以工作。
NSURL *soundURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Sound" ofType:@"mp3"]];
但是假设我在我尝试过的文档中有 Sound.mp3:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *strPointSound = [documentsDirectory stringByAppendingPathComponent:
[NSString stringWithFormat: @"/tours/media/%@", self.point.pointSound] ];
NSURL *soundURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:strPointSound ofType:@"mp3"]];
self.point.pointSound 是“Sound.mp3”。
亲切的问候。
【问题讨论】:
标签: ios nsurl nsdocumentdirectory