trying to fix adudio player bug, added audio play piwik tracking

This commit is contained in:
2018-04-18 10:02:59 +02:00
parent 249bc608b3
commit b6168089a7
2 changed files with 60 additions and 20 deletions
@@ -555,7 +555,8 @@
.emmit('stop-shuffle') .emmit('stop-shuffle')
.openDocument({ .openDocument({
nid:$link.attr('nid'), nid:$link.attr('nid'),
audio_url:$link.attr('audio_url') audio_url:$link.attr('audio_url'),
title:$link.find('.field--name-title').html()
}); });
return false; return false;
} }
@@ -759,6 +760,22 @@
this.emmit('audio-open-document', {caller:caller}); this.emmit('audio-open-document', {caller:caller});
// piwik
debugger;
if(typeof _paq !== 'undefined'){
// page tracking
// https://matomo.org/blog/2017/02/how-to-track-single-page-websites-using-piwik-analytics/
// _paq.push(['setCustomUrl', state.url]);
// _paq.push(['setDocumentTitle', data.title]);
// _paq.push(['trackPageView']);
// js event
// trackEvent(category, action, [name], [value])
if(typeof node.title != 'undefined'){
_paq.push(['trackEvent', 'Audio', 'play', node.title]);
}
}
this.launch(); this.launch();
}, },
launch(){ launch(){
@@ -792,6 +809,8 @@
this.updateLoadingBar(); this.updateLoadingBar();
}, },
updateLoadingBar(){ updateLoadingBar(){
// if (track.readyState === 4){
if(track.buffered.length>0){
this.$loader.css({ this.$loader.css({
'width':parseInt((100 * this.audio.buffered.end(0) / this.audio.duration), 10)+'%' 'width':parseInt((100 * this.audio.buffered.end(0) / this.audio.duration), 10)+'%'
}); });
@@ -802,6 +821,7 @@
}else{ }else{
//console.log('Audio fully loaded'); //console.log('Audio fully loaded');
} }
}
}, },
onCanplay(){ onCanplay(){
this.play(); this.play();
@@ -555,7 +555,8 @@
.emmit('stop-shuffle') .emmit('stop-shuffle')
.openDocument({ .openDocument({
nid:$link.attr('nid'), nid:$link.attr('nid'),
audio_url:$link.attr('audio_url') audio_url:$link.attr('audio_url'),
title:$link.find('.field--name-title').html()
}); });
return false; return false;
} }
@@ -759,6 +760,22 @@
this.emmit('audio-open-document', {caller:caller}); this.emmit('audio-open-document', {caller:caller});
// piwik
debugger;
if(typeof _paq !== 'undefined'){
// page tracking
// https://matomo.org/blog/2017/02/how-to-track-single-page-websites-using-piwik-analytics/
// _paq.push(['setCustomUrl', state.url]);
// _paq.push(['setDocumentTitle', data.title]);
// _paq.push(['trackPageView']);
// js event
// trackEvent(category, action, [name], [value])
if(typeof node.title != 'undefined'){
_paq.push(['trackEvent', 'Audio', 'play', node.title]);
}
}
this.launch(); this.launch();
}, },
launch(){ launch(){
@@ -792,6 +809,8 @@
this.updateLoadingBar(); this.updateLoadingBar();
}, },
updateLoadingBar(){ updateLoadingBar(){
// if (track.readyState === 4){
if(track.buffered.length>0){
this.$loader.css({ this.$loader.css({
'width':parseInt((100 * this.audio.buffered.end(0) / this.audio.duration), 10)+'%' 'width':parseInt((100 * this.audio.buffered.end(0) / this.audio.duration), 10)+'%'
}); });
@@ -802,6 +821,7 @@
}else{ }else{
//console.log('Audio fully loaded'); //console.log('Audio fully loaded');
} }
}
}, },
onCanplay(){ onCanplay(){
this.play(); this.play();