If you play a video after your sound, the OS will definitely โstopโ your background audio player. From your question, it seems that this is reproducible in 100% of cases, which will confirm this. Your only option is to restart the background audio player again after you call BackgroundAudioPlayer.Instance.Close() and then play your video. Which, as you said, will require reloading your playerโs DLL when starting BAP.
Update after comments
If you do not implement an audio streaming agent, but only an AudioPlayer agent, you are not going to kill anyway. The OS starts the process as necessary to force you to process the action (for example: user action, end of track, shutdown).
BackgroundAudioPlayer.Instance.Close() simply ensures that the OS frees up these resources for free in a script such as OP.
To restart the background sound, just call BackgroundAudioPlayer.Instance.Play() again.
source share