The incantation that you are looking for is “inhibit suspend”.
It’s not the first time that someone has asked for it in respect of playing music: Suspend to honour audio streaming?
Here is discussion of inhibiting suspend around an SSH session but the basic command should be similar: Login via SSH && suspend - #10 by dos
You wouldn’t be doing it from a service however.
You would want to look at man gnome-session-inhibit
And to be clear … this would inhibit suspend while the music player is running. It won’t know whether you are actually listening or even whether the music player is actually playing anything. ![]()