Spawn play ENOENT Nodejs

Asked

Viewed 68 times

0

I’m trying to use a library called steal:

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 me 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 don’t know what it could be, because I’ve tried it in many ways and nothing works.

  • Have you tried to isolate the mistake to find out what’s causing it? If you comment on the Troubadour.play line(__dirname+'/Assets/musics/infiel.mp3'); the error remains?

  • @André when I remove no error, the page in the browser is as if it had only been loading, but shows no error.

1 answer

1


From what I searched, this library (Troubadour) needs an audio player installed on your system, you can check the list of supported players on this page: https://github.com/jaredpetersen/troubadour/blob/master/lib/supportedAudioPlayers.json

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

This error may occur because Node is trying to run Sox, but it is not installed on the system.

  • I installed the SOX and now gave no more error, the only problem now is that it does not open the audio looks. It appears the message `Started' and then already 'Finished' and does not execute the audio, but I believe there is something else from the plugin

  • Are the Sox command and process as play? Set it in the system environment variables?

  • worked now, the problem that was not running is because the audio has to be in WAV :). Thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.