spawn play ENOENT NodeJS

0

I'm trying to use a library called troubadour :

const Troubadour = require('troubadour');
const troubadour = new Troubadour('sox');

app.get('/playmusics', function(req, res){

    troubadour.on('start', () => {
      // Do something here when the audio starts playing
      console.log('Começou');
    });

    troubadour.on('end', () => {
      // Do something here when the audio finishes playing
      console.log('Finalizado');
    });

    troubadour.play(__dirname+'/assets/musics/infiel.mp3');

    troubadour.on('error', (error) => {
      // Do something here to handle the errors
      console.log('Erro :( : ', error);
    });
});

But when I enter the URL /playmusics the server drops and returns the error in the terminal:

events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: spawn play ENOENT
    at exports._errnoException (util.js:1026:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:359:16)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)

I do not know what it can be, because I've tried it in many ways and nothing works.

    
asked by anonymous 13.01.2017 / 00:25

1 answer

1

As I researched, this library (Troubadour) needs an audio player installed on your system, you can check the list of supported players on this page: link

In your case, you are using sox ( const troubadour = new Troubadour('sox'); ). Make sure you have it installed on your system and configured as it asks for the link above that I sent you, the process needs to have the name play and the command as well.

This error can occur because the Node is attempting to execute sox, but it is not installed on the system.

    
13.01.2017 / 00:37