Skip to content

Commit

Permalink
fix bug when playnext
Browse files Browse the repository at this point in the history
  • Loading branch information
lucbu committed Apr 19, 2017
1 parent 30e70b7 commit 886962d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion player/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Player.prototype.playSound = function(sound, cb) {
console.log('Start music "' + sound.title + '"');
player.status = 'onair';
console.log(sound.filename)
player.audio = spawn('vlc', [sound.filename, '--intf="dummy"', '--play-and-exit']);
player.audio = spawn('vlc', [sound.filename, '--intf' ,'dummy', '--play-and-exit']);
player.audio.on('exit', function(code){
console.log('End music ' + sound.filename);
player.status = 'offair'
Expand Down
39 changes: 19 additions & 20 deletions playlist/Playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Playlist.prototype.playNext = function(force){
force=false;
}
if(force){
this.queue.shift();
var isWin = /^win/.test(os.platform());
if(!isWin) {
this.player.audio.kill('SIGKILL');
Expand All @@ -30,28 +29,28 @@ Playlist.prototype.playNext = function(force){
cp.exec('taskkill /PID ' + this.player.audio.pid + ' /T /F', function (error, stdout, stderr) {});
}
this.player.status = 'offair'
} else {
var playlist = this;
var next = this.queue[0];
this.playing = undefined;
if('undefined' !== typeof next){
if(next.like >= next.dislike){
this.playing = next;
this.player.playSound(next.sound, function(){
playlist.queue.shift();
next.sound.deleteFile();
if('undefined' !== next.endPlaying){
next.endPlaying()
}
playlist.playNext();
});
} else {
this.queue.shift();
} else{
var playlist = this;
var next = this.queue[0];
if('undefined' !== typeof next){
if(next.like >= next.dislike){
this.playing = next;
this.player.playSound(next.sound, function(){
playlist.queue.shift();
next.sound.deleteFile();
this.playNext();
}
if('undefined' !== next.endPlaying){
next.endPlaying()
}
this.playing = undefined;
playlist.playNext();
});
} else {
this.queue.shift();
next.sound.deleteFile();
this.playNext();
}
}
}
}

module.exports = Playlist;

0 comments on commit 886962d

Please sign in to comment.