fixed audioplayer timertohide bug

This commit is contained in:
Bachir Soussi Chiadmi
2018-03-19 23:26:29 +01:00
parent 563f81c1b1
commit 9da225984b
5 changed files with 22 additions and 12 deletions
@@ -593,10 +593,10 @@
}; };
// show opened audio node // show opened audio node
function openNodeByNid(nid){ function openNodeByNid(nid){
console.log('Corpus openNode()', nid); // console.log('Corpus openNode()', nid);
closeNode(); closeNode();
if(typeof _nodes_Nid_Id[nid] != 'undefined'){ if(typeof _nodes_Nid_Id[nid] != 'undefined'){
console.log('node exists'); // console.log('node exists');
_node_opened_id = _nodes_Nid_Id[nid]; _node_opened_id = _nodes_Nid_Id[nid];
_nodes[_nodes_Nid_Id[nid]].open(); _nodes[_nodes_Nid_Id[nid]].open();
} }
@@ -806,7 +806,7 @@
} }
}) })
.on('audio-node-opened', function(e){ .on('audio-node-opened', function(e){
console.log('Corpus audio-node-opened', e); // console.log('Corpus audio-node-opened', e);
openNodeByNid(e.nid); openNodeByNid(e.nid);
}) })
.on('audio-node-closed', function(e){ .on('audio-node-closed', function(e){
@@ -593,10 +593,10 @@
}; };
// show opened audio node // show opened audio node
function openNodeByNid(nid){ function openNodeByNid(nid){
console.log('Corpus openNode()', nid); // console.log('Corpus openNode()', nid);
closeNode(); closeNode();
if(typeof _nodes_Nid_Id[nid] != 'undefined'){ if(typeof _nodes_Nid_Id[nid] != 'undefined'){
console.log('node exists'); // console.log('node exists');
_node_opened_id = _nodes_Nid_Id[nid]; _node_opened_id = _nodes_Nid_Id[nid];
_nodes[_nodes_Nid_Id[nid]].open(); _nodes[_nodes_Nid_Id[nid]].open();
} }
@@ -806,7 +806,7 @@
} }
}) })
.on('audio-node-opened', function(e){ .on('audio-node-opened', function(e){
console.log('Corpus audio-node-opened', e); // console.log('Corpus audio-node-opened', e);
openNodeByNid(e.nid); openNodeByNid(e.nid);
}) })
.on('audio-node-closed', function(e){ .on('audio-node-closed', function(e){
@@ -71,7 +71,7 @@
}; };
function onResultsLoaded(data){ function onResultsLoaded(data){
console.log('EdlpSearch onResultsLoaded()', data); // console.log('EdlpSearch onResultsLoaded()', data);
_$form.removeClass('ajax-loading'); _$form.removeClass('ajax-loading');
_$body.removeClass('ajax-loading'); _$body.removeClass('ajax-loading');
@@ -96,7 +96,7 @@
}; };
function onSearchClosed(e){ function onSearchClosed(e){
console.log('Edlp Search onSearchClosed()', e); // console.log('Edlp Search onSearchClosed()');
$('div[theme="edlp_search_results"]').remove(); $('div[theme="edlp_search_results"]').remove();
// trigger event // trigger event
_$body.trigger({'type':'search-closed'}); _$body.trigger({'type':'search-closed'});
@@ -143,6 +143,7 @@
this.launch(); this.launch();
}, },
launch(){ launch(){
this.clearTimeOutToHide();
this.setSRC(this.historic[this.currentHistoricIndex].audio_url); this.setSRC(this.historic[this.currentHistoricIndex].audio_url);
this.loadNode(this.historic[this.currentHistoricIndex].nid); this.loadNode(this.historic[this.currentHistoricIndex].nid);
// emmit new playing doc (e.g.: corpus map nowing that audio played from RandomPlayer) // emmit new playing doc (e.g.: corpus map nowing that audio played from RandomPlayer)
@@ -157,7 +158,6 @@
// audio functions // audio functions
setSRC(url){ setSRC(url){
// console.log('AudioPlayer setSRC : url', url); // console.log('AudioPlayer setSRC : url', url);
this.clearTimeOutToHide();
this.audio.src = url; this.audio.src = url;
}, },
onLoadedmetadata(){ onLoadedmetadata(){
@@ -207,6 +207,7 @@
} }
}, },
stop(){ stop(){
console.log('AudioPlayer stop()');
this.audio.pause(); this.audio.pause();
this.timeOutToHide(); this.timeOutToHide();
}, },
@@ -268,15 +269,19 @@
} }
}, },
timeOutToHide(){ timeOutToHide(){
console.log('AudioPlayer timeOutToHide()');
this.clearTimeOutToHide(); this.clearTimeOutToHide();
this.hideTimer = setTimeout(this.hide.bind(this), this.hideTimeMS); this.hideTimer = setTimeout(this.hide.bind(this), this.hideTimeMS);
}, },
clearTimeOutToHide(){ clearTimeOutToHide(){
console.log('AudioPlayer clearTimeOutToHide()',this.hideTimer);
if(this.hideTimer){ if(this.hideTimer){
clearTimeout(this.hideTimer); clearTimeout(this.hideTimer);
this.hideTimer = false;
} }
}, },
hide(){ hide(){
console.log('AudioPlayer hide()');
this.$container.removeClass('visible'); this.$container.removeClass('visible');
// trigger highlighted node remove on corpus map // trigger highlighted node remove on corpus map
_$corpus_canvas.trigger('audio-node-closed'); _$corpus_canvas.trigger('audio-node-closed');
@@ -578,7 +583,7 @@
this.active = _audio_player.shuffle_is_active = false; this.active = _audio_player.shuffle_is_active = false;
this.$btn.removeClass('is-active'); this.$btn.removeClass('is-active');
// stop audio player // stop audio player
_audio_player.stop(); // _audio_player.stop();
}, },
next(){ next(){
if(this.active && this.shuffledPlaylist.length > 0) if(this.active && this.shuffledPlaylist.length > 0)
@@ -143,6 +143,7 @@
this.launch(); this.launch();
}, },
launch(){ launch(){
this.clearTimeOutToHide();
this.setSRC(this.historic[this.currentHistoricIndex].audio_url); this.setSRC(this.historic[this.currentHistoricIndex].audio_url);
this.loadNode(this.historic[this.currentHistoricIndex].nid); this.loadNode(this.historic[this.currentHistoricIndex].nid);
// emmit new playing doc (e.g.: corpus map nowing that audio played from RandomPlayer) // emmit new playing doc (e.g.: corpus map nowing that audio played from RandomPlayer)
@@ -157,7 +158,6 @@
// audio functions // audio functions
setSRC(url){ setSRC(url){
// console.log('AudioPlayer setSRC : url', url); // console.log('AudioPlayer setSRC : url', url);
this.clearTimeOutToHide();
this.audio.src = url; this.audio.src = url;
}, },
onLoadedmetadata(){ onLoadedmetadata(){
@@ -207,6 +207,7 @@
} }
}, },
stop(){ stop(){
console.log('AudioPlayer stop()');
this.audio.pause(); this.audio.pause();
this.timeOutToHide(); this.timeOutToHide();
}, },
@@ -268,15 +269,19 @@
} }
}, },
timeOutToHide(){ timeOutToHide(){
console.log('AudioPlayer timeOutToHide()');
this.clearTimeOutToHide(); this.clearTimeOutToHide();
this.hideTimer = setTimeout(this.hide.bind(this), this.hideTimeMS); this.hideTimer = setTimeout(this.hide.bind(this), this.hideTimeMS);
}, },
clearTimeOutToHide(){ clearTimeOutToHide(){
console.log('AudioPlayer clearTimeOutToHide()',this.hideTimer);
if(this.hideTimer){ if(this.hideTimer){
clearTimeout(this.hideTimer); clearTimeout(this.hideTimer);
this.hideTimer = false;
} }
}, },
hide(){ hide(){
console.log('AudioPlayer hide()');
this.$container.removeClass('visible'); this.$container.removeClass('visible');
// trigger highlighted node remove on corpus map // trigger highlighted node remove on corpus map
_$corpus_canvas.trigger('audio-node-closed'); _$corpus_canvas.trigger('audio-node-closed');
@@ -578,7 +583,7 @@
this.active = _audio_player.shuffle_is_active = false; this.active = _audio_player.shuffle_is_active = false;
this.$btn.removeClass('is-active'); this.$btn.removeClass('is-active');
// stop audio player // stop audio player
_audio_player.stop(); // _audio_player.stop();
}, },
next(){ next(){
if(this.active && this.shuffledPlaylist.length > 0) if(this.active && this.shuffledPlaylist.length > 0)