문제

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