خرید بک لینک

Vote count: 0

I want to play song using AVAudioPlayer. But this is does not work some time. I did not get what is the issue. I'm using this below code to play mp3 file from local.

    NSString *soundFile;
    soundFile = [[NSBundle mainBundle] pathForResource:@"notification_sound" ofType:@"mp3"];
    NSURL *fileURL = [NSURL fileURLWithPath:soundFile];
    self.playerAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
    [[AVAudioSession sharedInstance] setActive: YES error: nil];
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
    self.playerAudio.numberOfLoops = -1;
    self.playerAudio.volume=1;
    if([self.playerAudio prepareToPlay])
    {
        NSLog(@"Prepare to play successfully");
        [self.playerAudio play];
    }

if([self.playerAudio prepareToPlay]) this condition never be satisfied why this is happened please help me to solved this issue.

Thanks in advance

asked 49 secs ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 14 خرداد 1395 ساعت: 11:47

صفحه بندی