Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am creating application for play mp3 in iphone
i copy .mp3 file in Resource folder and the framework is also available
and my code is runnig i am not getting any error but i am not hearing sound by headphone

code- (void)viewDidLoad {
[super viewDidLoad];
NSString *path = [[NSBundle mainBundle]pathForResource:@"dtph" ofType:@"mp3"];
NSURL *file=[[NSURL alloc]initFileURLWithPath:path];
AVAudioPlayer *p=[[AVAudioPlayer alloc]initWithContentsOfURL:file error:nil];
[file release];
self.player = p;
[p release];
[player prepareToPlay];
[player setDelegate:self];


}
-(IBAction) play{
//self.playbutton.enabled = NO;
//[player play];
}

plz help me
Posted
Updated 25-Jul-11 2:27am
v2

1 solution

I'm not an export on Objective-C programming, but shouldn't the AVAudioPlayer variable be a class member ?

Now, it seems your are creating an instance of the AVAudioPlayer and release it.

what does that do ?
MIDL
self.player = p;
[p release];


will it also release self.player ?

have a look at :
http://mobileorchard.com/easy-audio-playback-with-avaudioplayer/[^]

Max.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900