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.