If you want it to always work at the position of the player, you could also do this:
execute as <player> at <player> run playsound <sound> <player> ~ ~ ~ [volume] [pitch] [minimumVolume]
If you want it to always work at the position of the player, you could also do this:
execute as <player> at <player> run playsound <sound> <player> ~ ~ ~ [volume] [pitch] [minimumVolume]