It would be convenient if audio.fade() had something like an optional onComplete callback.
Potential usage scenario: You have two streaming songs on separate, dedicated channels. You don’t ever want to literally stop() either one and lose its position, just pause one, resume the other, repeat - so audio.fadeOut() isn’t an option. But you also require a smooth volume crossfade, so you’re not content to simply call:
audio.pause(song1Channel)
audio.resume(song2Channel)
Instead, you’d like to do something like this:
– do a fade-out-then-pause on first song
local function pauseSong1() audio:pause(song1Channel) end
audio.fade({channel=song1Channel, time=300, volume=0, onComplete=pauseSong1})
– do a resume-with-fade-in on the other song
audio.setVolume(0, { channel=song2Channel})
audio.resume(song2Channel)
audio.fade({ channel=song2Channel, time=300, volume=1}) – callback not needed
But of course you can’t do that at present. So as a workaround you also create a timer to pause the fading-out song some short time after the fade is expected to end. It’s kludgey, and takes more code to implement and keep track of, but it works, mostly.
A callback would be much sexier. :)