AVAudioPlayer volume range?

We used AVAudioPlayer in the Cocos2d project. The sound change is not as expected.

CODE:

NSURL* tapSound = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"tap" ofType:@"m4a"]]; mClickSound = [[AVAudioPlayer alloc] initWithContentsOfURL: tapSound error: nil]; [mClickSound prepareToPlay]; mClickSound.numberOfLoops = 0; [mClickSound setVolume: 1.0f]; mRandomLoopMusic = NULL; 

In the above code, I install volume 1.0, but the volume of music is not full. When I set 10.0f then it increases. So, I doubt what is the volume range? In the AVAudioPlayer document, 0 - 1 is the range, but in the cocos2D example, it is not true. How can we limit the audio range to 0 - 1?

+4
source share
1 answer

To change the volume of the device itself, you must set

 [mClickSound setVolume:1.0]; [[MPMusicPlayerController iPodMusicPlayer] setVolume:1.0]; 

You will also need to add MediaPlayer.

0
source

Source: https://habr.com/ru/post/1389044/


All Articles