我正在创建一个带有背景音乐循环的SpriteKit游戏.问题是音乐太大了.如何降低音量?
这是我用来设置音乐的代码
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()
你试过这个吗?
原文链接:https://www.f2er.com/swift/318995.htmlbackGroundMusic.volume = 0.5
音量从0.0到1.0(全音量). https://developer.apple.com/library/prerelease/ios/documentation/AVFoundation/Reference/AVAudioPlayerClassReference/index.html