我有个问题。以下代码无法播放任何内容。根据编译器,没有错误。我已经建立了必要的联系。事实上,如果我不使用AVAudioPlayer,如果我使用AudioServicesPlaySystemSound,一切都能工作。如果有人能帮助me.Because,我会很高兴,我需要在我的项目中使用AVAudioPlayer,并且我已经尝试了我所知道的一切。
谢谢
.h文件
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <AudioToolbox/AudioToolbox.h>
@property(strong,nonatomic) AVAudioPlayer *audioPlayer;
- (IBAction)cal:(id)sender;.m文件
- (IBAction)cal:(id)sender {
NSString *path = [[NSBundle mainBundle] pathForResource:@"demo" ofType:@"mp3"];
NSURL *pathURL = [NSURL fileURLWithPath : path];
audioPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:pathURL error:nil];
[audioPlayer play];
}发布于 2013-06-19 07:34:43
好的,经过几个小时的尝试,我很难相信解决了issue.It,但是我所做的是将mp3文件重命名(没有转换)为m4a,并将源代码中的相应代码更改为m4a.That。
https://stackoverflow.com/questions/17176095
复制相似问题