小编Qua*_*aso的帖子

用AVFoundation播放wav声音文件

我正在使用AVFoundation播放wav文件.但我无法发挥它.也没有出现任何错误或警告.

XCode是4.2,设备是iOS 5.

- (IBAction) playSelectedAlarm:(id)sender {

UIButton *button = (UIButton *)sender;

int bTag = button.tag;

NSString *fileName = [NSString stringWithFormat:@"%d23333", bTag];

NSLog(@"%@", fileName);

NSString *path = [[NSBundle mainBundle] pathForResource:fileName ofType:@"wav"];

NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: path];

AVAudioPlayer *theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:NULL];

theAudio.volume = 1.0;

theAudio.delegate = self;

[theAudio prepareToPlay];

[theAudio play];

}
Run Code Online (Sandbox Code Playgroud)

xcode wav avfoundation ios

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

avfoundation ×1

ios ×1

wav ×1

xcode ×1