5

我正在使用AVAudioPlayer. 声音每隔几秒钟从一个NSTimer方法中重放一次。第一次播放声音时,音量很好,但在随后的播放中,音量非常低,几乎听不见。有时音量会在第一次播放的中途发生。这发生在 iPad 3 上,因此扬声器选择不是问题。

NSError *phoneCallError;
NSURL *phoneCallUrl = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/phone-calling-1.wav", [[NSBundle mainBundle] resourcePath]]];
AVAudioPlayer *phoneCallPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:phoneCallUrl error:&phoneCallError];
if (phoneCallError) {
    NSLog(@"%@: %@", self, phoneCallError);
} else {
    phoneCallPlayer.numberOfLoops = 0;
}

NSTimer方法只是调用[phoneCallPlayer play]. 任何时候都不会以编程方式设置音量。有什么建议么?谢谢。

4

1 回答 1

-1
- (IBAction)volumeDidChange:(UISlider *)slider {
//Handle the slider movement
[audioPlayer setVolume:[slider value]];

}

should be slider minimum value 0 and maximum 1.

于 2012-08-18T10:51:47.440 回答