我正在创建一个应用程序,其中按下按钮时播放声音并使用可以调节音量的 UISlider。有时声音的音量太高,有时甚至在将 iphone 的音量增加到最大之后也太低。我怎样才能将音量保持在高位?将系统音量与滑块音量集成在一起的任何可能方式?我猜使用 MPVolumview 会拒绝我的应用程序。我在按钮触摸上使用的代码是这样的
NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
resourcePath = [resourcePath stringByAppendingString:@"/sound.mp3"];
NSLog(@"Path to play: %@", resourcePath);
player = [[AVAudioPlayer alloc] initWithContentsOfURL:
[NSURL fileURLWithPath:resourcePath] error:&err];
player.delegate = self;
[player play];
player.volume=.50;
player.numberOfLoops=-10;
-(IBAction)slidervaluechanged
{ player.volume=slider.value; }
}