Я использую 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];
}
NSError *audioError = nil; AVAudioPlayer *theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:&audioError]; if(audioError != nil) { NSLog(@"An audio error occurred: \"%@\"", audioError); } else { [theAudio prepareToPlay]; [theAudio play]; }
- person Quaso   schedule 30.11.2011