Learn How To Create Your Own iPhone and iPad Apps!

Forums

Post Reply
Forum Home > Problems > Auto Play Sound

Malk0
Member
Posts: 1

Ok, So I want to have intro music play when my app launches. I have followed the tut to the T and all the code checks out with no errors but when I go to test it I hear no sound. Yes I have added the AVFoundation framework. Even tried it with the AudioToolbox framewrok but nothing works.

I am running Xcode 4.3.2. I read somewhere that there was a bug in the beta version of this build of Xcode but surely Apple would of fixed this before releasing the final version, right?

Anyway it's doing my head in as I really want my app to have this feature in it. Any help/suggestions would be greatly appreciated

Thanks guys

--

Malko

May 21, 2012 at 9:09 AM Flagged Quote & Reply

evilmatt10
Member
Posts: 3

Where is the code implemented? In the VeiwDidLoad?

--

-Code Monkey

May 22, 2012 at 11:08 PM Flagged Quote & Reply

crutch
Member
Posts: 1

I'm having the same problem in XC 4.3.2.  Any more suggestions?  My code looks like this:

#import "a1ViewController.h"

#import

 

@implementation a1ViewController

 

-(void)awakeFromNib {

NSString *path = [[NSBundle mainBundle] pathForResource:@"gunshot"ofType:@"mp3"];

AVAudioPlayer* theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];

[theAudio play];

}

 

- (void)viewDidLoad

{

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

}

 

- (void)viewDidUnload

{

[super viewDidUnload];

// Release any retained subviews of the main view.

}

 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {

return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);

} else {

return YES;

}

}

 

@end

 



June 24, 2012 at 2:37 PM Flagged Quote & Reply

You must login to post.