Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


playing back audio using avaudioplayer ios 7


playing back audio using avaudioplayer ios 7  using -'ios,core-audio'

I'm struggling to follow Apple's documentation regarding playing back a small .wav file using the AVAudioPlayer class.  I'm also not sure what toolboxes I need for basic audio playback.  So far I have imported:

AVFoundation.framework
CoreAudio.framework
AudioToolbox.framework


Here is my code .h and .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


I don't seem to have any errors.  However, I am not getting any audio.
    

asked Sep 22, 2015 by amit.gupta
0 votes
7 views



Related Hot Questions



Government Jobs Opening


...