Iphone Simulator 4.3中没有声音/音量。但在Iphone模拟器5.1中播放正常

时间:2012-07-22 13:51:48

标签: xcode4.3 ios4

我正在开发一个iPhone应用程序来播放声音文件。我的部署目标是4.0。在尝试在iPhone模拟器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];
}

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

0 个答案:

没有答案