Воспроизведение аудио с помощью AVAudioPlayer iOS 7
Я изо всех сил пытаюсь следовать документации Apple относительно воспроизведения небольшого.wav
файл с использованиемAVAudioPlayer
учебный класс. Я также не уверен, какие наборы инструментов мне нужны для базового воспроизведения звука. Пока я импортировал:
AVFoundation.framework
CoreAudio.framework
AudioToolbox.framework
Вот мой код.h
а также.m
:
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
@interface ViewController : UIViewController <AVAudioPlayerDelegate>
- (IBAction)playAudio:(id)sender;
@end
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (IBAction)playAudio:(id)sender {
NSLog(@"Button was Pressed");
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"XF_Loop_028" ofType:@"wav"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
// create new audio player
AVAudioPlayer *myPlayer = [[AVAudioPlayer alloc]initWithContentsOfURL:fileURL error:nil];
[myPlayer play];
}
@end
Кажется, у меня нет ошибок. Тем не менее, я не получаю аудио.