Question

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];
} 
Was it helpful?

Solution

Try this. remove .mp3 from Path resource.

NSString *audiopath =[[NSBundle mainBundle] pathForResource:@ "1Abhi Kuch Dino Se" ofType:@ "mp3"];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top