Adding Audio

Discussion in 'iOS Development' started by wearmaize, Apr 15, 2009.

  1. wearmaize

    wearmaize Active Member

    Joined:
    Feb 13, 2008
    Messages:
    2,442
    Likes Received:
    13
    Device:
    iPhone 4S (Black)
    OK, I'm trying to get audio to play when I push a button. Here is the code I'm using:

    Code:
    #import "MainView.h"
    #import "AVFoundation/AVAudioplayer.h"
    
    @implementation MainView
    - (IBAction)pushbutton {
    	
    	NSString *path = [[NSBundle mainBundle] pathForResource:@"Victors" ofType:@"aiff"];
    	AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL: [NSURL fileURLWithPath:path] error:NULL];
    	theAudio.delegate = self;
    	[theAudio play];
        
    }
    @end
    I get the error:
    Code:
     Line Location Tool:0: ".objc_class_name_AVAudioPlayer", referenced from:
    
    Any idea why?

    EDIT: The name of the file is "Victors" and the extension is ".aiff"
  2. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    did you added AVFoundation framework to your projects?
  3. wearmaize

    wearmaize Active Member

    Joined:
    Feb 13, 2008
    Messages:
    2,442
    Likes Received:
    13
    Device:
    iPhone 4S (Black)
    Yes, I believe it is. Where would I be able to see it? I am almost positive I added it. I didn't know if I screwed up the code or something.
  4. Cyanidepoison

    Cyanidepoison Active Member

    Joined:
    Jan 18, 2008
    Messages:
    1,076
    Likes Received:
    2
    Spelling the headers right/ using the right headers would probably help.
  5. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    It should be under framework group in Xcode.
  6. spoonforknife

    spoonforknife Retired Moderator

    Joined:
    Nov 15, 2007
    Messages:
    6,896
    Likes Received:
    317
    Code:
    #import <AVFoundation/AVAudioPlayer.h>
  7. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    yes, fix your include error. but your program is not being linked against that framework, which is your problem
  8. wearmaize

    wearmaize Active Member

    Joined:
    Feb 13, 2008
    Messages:
    2,442
    Likes Received:
    13
    Device:
    iPhone 4S (Black)
    That would make sense. What an idiot error! Thanks!

Share This Page