How to access the audio files that are stored locally in the application and display in the tableview
i have an application in which i have taken 5 audio files and dragedd into my resources folder.Now i want to access this folder i.e when i click on a tableview cell all the audio files should be shown in another tableview cell & when i select a particular audio file in the tableview cell the tableview should so a checkmark and its value mus开发者_JS百科t be set to the detailtext of previous cell.Thanks
You can read your audio files from resources folder as,
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/audiofilename.mp3", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops = -1;
if (audioPlayer == nil)
NSLog([error description]);
else
[audioPlayer play];
精彩评论