samedi 26 août 2017

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
            }
        }
    },
});

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




Aucun commentaire:

Enregistrer un commentaire