You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to do volume control when playing but the only way to do that is through creating a new instance that I then have to keep track of since if it goes out of scope it doesn't play. Perhaps I'm doing it wrong. Ideally I would like to do something like Sound.play(url: url, withVolume:0.3 ....
Is this possible?
The text was updated successfully, but these errors were encountered:
Creating an instance is currently the only option to control the volume. However, you could overcome this with a simple wrapper for your sounds, like the following:
struct Sounds {
static var globalVolume: Float = 0.5 {
didSet {
mySound1?.volume = globalVolume
//add other sounds here
}
}
static var mySound1: Sound? = {
if let url = Bundle.main.url(forResource: "myFile", withExtension: "wav") {
let sound = Sound(url: url)
sound?.volume = Sounds.globalVolume
return sound
}
return nil
}()
//add more sounds here
}
Trying to do volume control when playing but the only way to do that is through creating a new instance that I then have to keep track of since if it goes out of scope it doesn't play. Perhaps I'm doing it wrong. Ideally I would like to do something like Sound.play(url: url, withVolume:0.3 ....
Is this possible?
The text was updated successfully, but these errors were encountered: