Commit d44a237e authored by fred's avatar fred

playlist: don't duplicate same sound

parent ea993217
......@@ -170,6 +170,11 @@
},
// Create a public method.
registerAudio: function(audio,success) {
var sound_id = audio.data('sound-id');
if (this.playlistContainer.find('[data-sound-id=' + sound_id + ']').length) {
/* already in playlist */
return;
}
var audioObj = this.jsonifyAudio(audio);
var htmlAudio = this._htmlifyJsonSound(audioObj);
this.playlistContainer.append(htmlAudio);
......@@ -231,6 +236,10 @@
}
return this.isActive;
},
playSoundId: function(sound_id) {
this.playlistContainer.find('audio[data-sound-id="' + sound_id + '"]'
).trigger('beforePlay').trigger('play');
},
// Play next sound
playPauseList: function() {
if(this.controlButtons['playpause'].hasClass('icon-play')){
......
......@@ -344,11 +344,12 @@ $(function() {
});
$('[data-player-action]').on('click',function(){
var audio = $('#'+$(this).attr('data-player-audio'));
var sound_id = audio.data('sound-id');
if($(this).attr('data-player-action') == "registerAudio"){
$localList.playlist("registerAudio",audio,doLog(audio.attr('title')+' has been added to your playlist.','ok'));
}else if($(this).attr('data-player-action') == "playAudio"){
$localList.playlist("registerAudio",audio,doLog(audio.attr('title')+' will play soon.','ok'));
$localList.playlist("playLast");
$localList.playlist("playSoundId", sound_id);
}else{
$localList.playlist($(this).attr('data-player-action'));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment