How to check if a mob exists

Im trying to make a boss music datapack/resource pack and for the ender dragon i just need a simple way to basicly just check if the enderdragon is there, and if yes, play this sound. if no, dont play the sound and stop the sound if its playing. Does anybody know a good way to do this?

Continue to help post