[ad_1]
I’ve an AVAudioPlayer occasion referred to as participant. After I set the quantity as follows, it really works as anticipated: the quantity begins at 1 and regularly fades to 0.
participant.quantity = 1
participant.setVolume(0, fadeDuration: 3)
However there’s a downside when I attempt to go the opposite means, as follows, beginning at quantity 0 and fading in to 1.
participant.quantity = 0
participant.setVolume(1, fadeDuration: 3)
After I run this, the quantity instantly jumps to quantity 1 with none fade. This looks like a bug to me, as a result of the conduct works with one set of values however not the opposite set of values.
I did discover a workaround right here, which wraps the quantity fade in a DispatchQueue name.
participant.quantity = 0
DispatchQueue.principal.async {
self.audioPlayer?.setVolume(1, fadeDuration: 3)
}
This works. However I do not perceive why you want a DispatchQueue name to make it work a technique, however not the opposite means. Can anybody shed some gentle on this? I am questioning if that is an precise bug, or possibly I am simply doing one thing incorrect or not understanding one thing accurately.
[ad_2]
