I’ve implemented AVAudioPlayer into my iPhone app but the audio being played is far too loud. To quieten the sound slightly, I changed the volume to 0.2f to see if it would have any effect. The volume stayed exactly the same. Here’s the code I’m using:
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Blip.mp3", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops = 0;
[audioPlayer setVolume:0.2f];
if (audioPlayer == nil)
NSLog(@"Whoopsies, there was an error with the sound!");
else
[audioPlayer play];
Why won’t this turn the volume down?
Can somebody explain how I can?
Thanks!
Replace your code:
with following code:
Hope this helps you.