NSP
NSP

Reputation: 131

using slider change the volume in AVAudioPlayer in iphone sdk

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?

Upvotes: 0

Views: 2324

Answers (1)

Eugene
Eugene

Reputation: 10045

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;
}

Upvotes: 3

Related Questions