shime / play-sound

Play sounds by shelling out to one of the available audio players.
MIT License
207 stars 31 forks source link

[Error: Couldn't find a suitable audio player] #10

Closed prithviraj99 closed 7 years ago

prithviraj99 commented 8 years ago

I have installed mplayer for windows but still its giving this error. [Error: Couldn't find a suitable audio player]

shime commented 8 years ago

What happens if you specify a player manually?

var player = require('play-sound')({player: "mplayer"})
player.play('foo.mp3', function(err){})
prithviraj99 commented 8 years ago

{ [Error: spawn mplayer ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn mplayer', path: 'mplayer', spawnargs: [ './Ipl Trumpet Mix-(FreshMaza.co).mp3' ], cmd: 'mplayer ./Ipl Trumpet Mix-(FreshMaza.co).mp3' }

This is the error i'm getting.

ghost commented 8 years ago

@prithviraj99

Perhaps a stupid question, but did you install mplayer so it was available through the command line.

cmd > mplayer should not result in 'mplayer' is not recognized as an internal or external command. I can reproduce your error by specifying a player that is not available as a command and thus can't be spawned (ENOENT).

A quick Google gave me as first results mplayer binary executables for Windows, which can be used with play-sound though (and are easy portable), as:

var player = require('play-sound')({player: "/path/to/downloads/mplayer/mplayer.exe"})
player.play('foo.mp3', function(err){})

(cc @shime)

shime commented 7 years ago

Thanks @verth, closing due to inactivity.

avalanche1 commented 7 years ago

I'm having the same problem. I've followed all of @verth's advice and and get the same ENOENT error @prithviraj99 was having.

avalanche1 commented 7 years ago

Ok, I've found the root cause: I'm using this on windows and if I have file paths somewhere in the code - it gives ENOENT error. C:\Windows\Media\chimes.wav must use double slashes C:\\Windows\\Media\\chimes.wav

ps. thanks for the package!

shime commented 7 years ago

@avalanche1 glad you found the solution, closing this again.

harishvarma8055 commented 7 years ago

How can we stop the audio..It keeps on playing on my node js file.audio.kill() is not working.It says it is not a function

jjgonecrypto commented 7 years ago

Did you see the last example in the README? https://github.com/shime/play-sound#examples