Channel helper gets disabled when unity loses focus
Hi! So while I was trying to control audio with timescale, I noticed what seems to be a bug.
Issue - When unity loses focus, e.g I alt-tab to browser, channel helper gets disabled and I can't control the audio with timescale. It happens when audio file is set as non-looping. I noticed that BaseAudioChannelHelper for non-looping files has this check in update:
if (audioFile.loopMode == LoopMode.NoLooping)
{
// Disable self if not playing anymore
enabled = AudioSource.isPlaying;
}
It seems that AudioSource.isPlaying is returning false after unity gets unfocused, so the component gets disabled. My workaround for this is enabling the script back after returning to Unity. Seems to work fine.
private void OnApplicationPause(bool pauseState)
{
if (!pauseState)
{
if (_bgmChannelHelper.AudioSource.isPlaying)
{
_bgmChannelHelper.enabled = true;
}
}
}
Thanks for reporting the issue, you are correct in assuming this is a bug.
This issue will be fixed in the next update. In the meantime, your workaround shouldn't affect the rest of JSAM's behaviour. 👍