Closed matt-cook closed 9 years ago
which players do you have installed?
afplay only.
Hi, I have the same problem. I found out, it is more a bug of find-exec. It always returns null.
On myCLI (OS X 10.9.5) I do
which afplay
/usr/bin/afplay
So I tried to get the same output with exec-sync
var exec = require('exec-sync');
exec(['which afplay'], function(err, out, code) {
if (err instanceof Error)
throw err;
process.stderr.write(err);
process.stdout.write(out);
process.exit(code);
});
or
var command = require('find-exec')(["mplayer", "afplay", "cvlc"])
console.log(command)
and i got null. Unfortunately, I found no solution to the problem. But maybe this helps.
André
Thanks for bumping this. I guess it's an issue with exec-sync
and OSX. I've just bumped the version on NPM, so please try updating the package version with npm install play-sound
.
If that doesn't help, try running this
var exec = require('execSync').exec
console.log(exec('afplay').code) // should print 0
*Thank you for the quick reply! Unfortunately, the update did not help.
With your snippet and an installed execSync package I get a 1 on the console. In execSync instruction I found, that sometimes is the need to install node-gyp globally
npm install node-gyp -g
But after I have installed, it also returns 1; So I asked my self, what if afplay always returns 1, if you don't pass an argument? And I tried this:
var exec = require('execSync').exec;
console.log(exec('afplay assets/test.mp3').code);
Et voilá. C'est tout. It returns 0. It also return 1, if your argument is not a valid path to a sound file.
Maybe you can use commands like follows, to check the player exists
$ command -v foo >/dev/null 2>&1 || { echo >&2 "I require foo but it's not installed. Aborting."; exit 1; }
$ type foo >/dev/null 2>&1 || { echo >&2 "I require foo but it's not installed. Aborting."; exit 1; }
$ hash foo 2>/dev/null || { echo >&2 "I require foo but it's not installed. Aborting."; exit 1; }
André
Thanks for the suggestion André! Bumped the version on NPM again, it should be fixed now.
Hi shime,
sorry, find-exec still returns NULL on OS X with afplay.
var command = require('find-exec')(["mplayer", "afplay", "cvlc"])
console.log(command) // >> null
regards, André
LOL, I need to borrow a MacBook for this one.
Maybe https://saucelabs.com/ could help to get it stable. For Open Source projects it is for free and you can run your test code also on OS X.
https://docs.saucelabs.com/tutorials/node-js/ https://docs.saucelabs.com/tutorials/js-unit-testing/
André
Figured out it was a silly error from my side causing this, the regex /win/
was matching both win32
and darwin
, so I had to alter it a bit to match windows only. Just released v0.0.5
with the fix.
Worked correctly only when player was specified in options. OSX 10.10.1, Node.js 0.10.22