1

我正在开发一个 iPhone 应用程序来播放声音文件。我的部署目标是 4.0。尝试在 iPhone Simulator 4.3 中播放时,它播放时没有声音/音量。但它在模拟器 5.1 中运行良好。

我的代码:

NSString *fileName=[NSString stringWithFormat:@"book%i_chapter_%i",book_number,chapter_number];

NSString *path=[[NSBundle mainBundle] pathForResource:fileName ofType:@"mp3" inDirectory:nil];
NSURL *url = [NSURL fileURLWithPath:path];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
if(error)
{
    NSLog(@"Error in audio Player: %@",[error localizedDescription]);
}
else
{
    [audioPlayer prepareToPlay];
    //audioPlayer.delegate=self;
    [audioPlayer setVolume:20.0];
    [audioSlider setValue:0.0];
    [audioSlider setMaximumValue:[audioPlayer duration]];

    [audioPlayer play];
}

请帮我解决这个问题。谢谢

4

0 回答 0