Вопрос

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];
} 
Это было полезно?

Решение

Try this. remove .mp3 from Path resource.

NSString *audiopath =[[NSBundle mainBundle] pathForResource:@ "1Abhi Kuch Dino Se" ofType:@ "mp3"];
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top