Playing a sound as a value changes

I am developing a lobby for multiplayer online experiment. The lobby basically is a stage where the participants wait until we have the required number of people. I want to play a bell sound that I have in the project public directory public/newPlayerSound.mp3 … and I have the following helper:

Template.lobby_page.helpers({
    numWaiting(){
        if (Meteor.userId()){
            let lobby = Lobbies.findOne({players:Meteor.userId()});
            if (lobby){
                //play the newPlayerSound.mp3
                return lobby.players.length
            }
        }
    },
});

basically, I want to play the newPlayerSound.mp3 every-time the numWaiting() changes. What would be an easy way to do this?

On mobile you can only play sound after the user interacts with the page. Maybe you could loop a silent mp3 file when the user first interacts and then change the sound to newPlayerSound.mp3 when needed.

I haven’t tested this. It is just an idea.

Maybe you could take inspiration from this topic :slight_smile: ?