How can I play a sound when my meteor server restarts? -
i have 1 monitor , find hard keeping track of windows, , on top of that, have slow pc. @ text editor, not seeing if changes loaded meteor.js. there anyway play sound when meteor server restarts because of changes?
bonus points: different sound when there's error preventing startup.
edit: i'm using windows 7, i'd want know how on mac , linux.
you can use node this:
meteor add meteorhacks:npm
then run project meteor
create packages.json
file in root directory
add below package.json looks this:
{ "play": "0.5.0" }
create file on desktop, sound, e.g sound.wav
and play on startup: (server side code):
meteor.startup(function() { var play = meteor.npmrequire('play').play(); // play callback play.sound('~/desktop/sound.wav', function() { }); //if want know when player has defintely started playing play.on('play', function (valid) { console.log('i started playing!'); }); //if want know if can't play reason play.on('error', function () { console.log('i can't play!'); }); });
it should work on mac , windows too, make sure use correct path, may better off absolute path file c:\users....wav
you need 1 of following cli players play sound:
- afplay
- mplayer (easiest installed on os x brew install mplayer, on windows may help: http://www.mplayerhq.hu/docs/html/en/windows.html)
- mpg123
- mpg321
- play
you can install any, long platform can run 1 should ok.. if download raw binary of them sure add directory executables in path
environment variable.
Comments
Post a Comment