在指定的目录获取所有的MP3等音频文件, 然后使用SDK中AVAudioPlayer进行播放控制, 代码示例如下
首先取得指定路径的所有mp3文件
musicArray = [[NSMutableArray alloc]init];
//资源目录
NSString *resoucePath = [[NSBundle mainBundle]resourcePath];
NSLog(@"resoucePath:%@",resoucePath);
//取出资源目录下所有mp3文件
// NSArray *fileArray = [[NSBundle mainBundle]pathsForResourcesOfType:@"mp3" inDirectory:resoucePath];
NSArray *mp3Array = [NSBundle pathsForResourcesOfType:@"mp3" inDirectory:[[NSBundle mainBundle]resourcePath]];
for (NSString *filePath in mp3Array) {
//NSLog(@"filePath:%@",filePath);
//fileURLWithPath是初始化文件路径url得,urlWithPath是初始化网络链接得
NSURL *fileURL = [NSURL fileURLWi