iOS发音问题的讲解

来源:互联网 发布:mysql user host 编辑:程序博客网 时间:2024/05/02 10:48


1,导入   #import<AVFoundation/AVFoundation.h>

2

下面是代码实现部分

 NSString *fileName = [[NSBundle mainBundle] pathForResource:word                                                         ofType:@"mp3"];             NSURL *fileUrl = [NSURL fileURLWithPath:fileName];    NSError *error = nil;    AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileUrl error:&error];       if (!player) {           } else {        [player setNumberOfLoops:0]; //默认为0,即播放一次就结束;如果设置为负值,则音频内容会不停的循环播放下去。        [player setDelegate:self];        [player play]


注意在mrc下,不能释放 [player release] 否则读不出来,十分简单。

0 0