How to quickly decrease the volume of music?

I am creating a SpriteKit game with a background music loop. The problem is that the music is too loud. How to decrease the volume?

Here is the code I used to set up the music

var backGroundMusic = AVAudioPlayer() var bgMusicUrl:NSURL = NSBundle.mainBundle().URLForResource("BackGround", withExtension: "wav") backGroundMusic = AVAudioPlayer(contentsOfURL:bgMusicUrl, error: nil) backGroundMusic.numberOfLoops = (-1) backGroundMusic.prepareToPlay() backGroundMusic.play() 
+5
source share
1 answer

Have you tried this?

 backGroundMusic.volume = 0.5 

The volume goes from 0.0 to 1.0 (full volume). https://developer.apple.com/library/prerelease/ios/documentation/AVFoundation/Reference/AVAudioPlayerClassReference/index.html

+16
source

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


All Articles