问题
I am using this code
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/audiofile.mp3", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
player = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
player.numberOfLoops = -1;
if (player == nil)
NSLog(@"%@",[error description]);
else
[player play];
but i want to change the volume so how can i get the volume detail?
回答1:
Set up your UISlider. Register it to receive the ValueChanged events in IB or programmatically. Set its min value to 0 and max to 100. And that should be it.
- (void)sliderValueChanged:(UISlider *)slider {
myPlayer.volume = slider.value / 100.0;
}
来源:https://stackoverflow.com/questions/11795624/using-slider-change-the-volume-in-avaudioplayer-in-iphone-sdk