开发者

How to access the audio files that are stored locally in the application and display in the tableview

开发者 https://www.devze.com 2023-03-22 21:49 出处:网络
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

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

精彩评论

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