I have a node.js app which should plays 3 sounds to all of the sockets at a certain time with node.js.
How would I go about getting this to work? Should I have the sound clips on the app.js and somehow emit them? Or should I have them stored in the client Side HTML and a flag to play them emitted to the users?
Could I see examples of how to do the prefered method also? Thank you
I suggest you to make the 3 audio files public (for example /public/audio/1.mp3
and relative node routes) and then to split the problem in 2 sub-problems:
For example if you're using socket.io I suggest you this simple code (server side):
io.emit('play', { audio: '/public/audio/1.mp3'});
And, for example, this can be the client side code needed:
var socket = io.connect('/');
socket.on('play', function (data) {
// Here goes the 'HOW' piece of code
// to play the data.audio track
});