fixed random player

This commit is contained in:
2018-04-26 16:09:53 +02:00
parent b4c613c9a4
commit 168e1009e8
2 changed files with 31 additions and 16 deletions
@@ -884,6 +884,8 @@
this.currentHistoricIndex = historic_index;
}
// TODO: stop random player if playing from studio
this.emmit('audio-open-document', {caller:caller});
@@ -1126,17 +1128,19 @@
return this;
},
emmit(event_name, args){
console.log('AudioPlayer emmit() event_name', event_name);
console.log('AudioPlayer emmit() handlers', this.event_handlers[event_name]);
console.log('AudioPlayer emmit()', event_name, args, this.event_handlers[event_name]);
// console.log('AudioPlayer emmit() handlers', this.event_handlers[event_name]);
var handler;
var args = args || {};
for (var i = this.event_handlers[event_name].length-1; i >= 0 ; i--) {
handler = this.event_handlers[event_name][i];
// console.log('AudioPlayer emmit() loop handler', handler);
setTimeout(function(){
console.log('AudioPlayer emmit() timeout handler', handler);
handler(args);
}, 0);
(function(handler, args){
setTimeout(function(){
// console.log('AudioPlayer emmit() timeout handler', handler);
handler(args);
}, 0);
}(handler, args));
}
return this;
},
@@ -1167,8 +1171,11 @@
// attach an event on AudioPlayer
_audioPlayer
.on('audio-ended', this.onAudioPlayerEnded.bind(this))
.on('audio-play-next', this.onAudioPlayNext.bind(this))
.on('audio-ended', this.onAudioPlayerEnded.bind(this))
// .on('audio-ended', function(e){
// console.log('RandomPlayer, audio-ended', e);
// })
.on('stop-shuffle', this.stop.bind(this));
@@ -1226,12 +1233,16 @@
_audioPlayer.openDocument(this.shuffledPlaylist.splice(0,1)[0]);
},
onAudioPlayNext(){
//console.log('RandomPlayer : onAudioPlayNext()');
this.next();
console.log('RandomPlayer : onAudioPlayNext()');
if(this.active){
this.next();
}
},
onAudioPlayerEnded(){
console.log('RandomPlayer : onAudioPlayerEnded()');
this.next();
if(this.active){
this.next();
}
}
};
@@ -1334,7 +1345,9 @@
this.paused = false;
_audioPlayer.play();
}else{
_audioPlayer.openDocument(this.playlist[this.current_index], this);
// _audioPlayer;
_audioPlayer.emmit('stop-shuffle').openDocument(this.playlist[this.current_index], this);
// TODO: stop random player
}
this.setActiveItem().showHideControls();
},
@@ -1460,7 +1473,9 @@
}
},
onAudioPlayerEnded(){
this.next();
if(this.playing){
this.next();
}
},
// onAudioPlayNext(){
// this.next();