开发者

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜