我試圖從手機上的本地文件中獲取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」。
親切的問候。