Reputation: 5
In the following code there is no error, but it is still not playing the audio.
What am I doing wrong?
-(IBAction)buttonPressed:(id)sender
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"ABC"
message: @" ABC"
delegate: self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK",nil];
[alert show];
AVAudioPlayer *audioplayer;
NSString *audiopath = [[NSBundle mainBundle] pathForResource:@ "1Abhi Kuch Dino Se.mp3" ofType:@ "mp3"];
NSURL *audioURL = [NSURL fileURLWithPath:audiopath];
audioplayer = [[AVAudioPlayer alloc]initWithContentsOfURL:audioURL error:nil];
[audioplayer play];
}
Upvotes: 0
Views: 70
Reputation: 17585
Try this. remove .mp3
from Path resource.
NSString *audiopath =[[NSBundle mainBundle] pathForResource:@ "1Abhi Kuch Dino Se" ofType:@ "mp3"];
Upvotes: 1