Open developez opened 8 years ago
More info using events.
Code:
var Player = require('player');
var debug = require('debug')('player');
var songs = [__dirname + '/aran_voice_1.mp3'];
var player = new Player(songs);
player
.on('playing', function(song) {
console.log('I\'m playing... ');
})
.on('playend', function(song) {
console.log('Play done, Switching to next one ...');
})
.on('error', function(err) {
console.log('Error');
console.log(err);
})
.play(function(err, player){
console.log('playend!');
console.log(err);
});
The output is:
I'm playing...
Error
No next song was found
It seems that expect a new song, but I only give to player one song. Also, using "new Player('path');" fails.
Now I understand the error. As error event is not caught, the process fails, and in other hand, that error event is fired always on line 223 (this.emit('error', 'No next song was found')). I think that this line is a unnecessary.
I have the same error on mine :/ same I had to installl libasound2-dev and everything compile fine, but still have this error... did you find something ?
@Shuunen To resolve the error is to need rebuild the package. The problem is on the code because it always fires a event tagged as "error" when the song list finishes.
To deal with this, manage the "error" event.
.on('error', function(err) {
console.log('Error');
console.log(err);
})
why .next()
by default?
why throw exception if there is no next item?
I have got his code:
Error messages:
I am working in a rapsberry B+. I have to install "speaker" using npm and libasound2-dev.