trying to fix adudio player bug, added audio play piwik tracking
This commit is contained in:
@@ -555,7 +555,8 @@
|
||||
.emmit('stop-shuffle')
|
||||
.openDocument({
|
||||
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;
|
||||
}
|
||||
@@ -759,6 +760,22 @@
|
||||
|
||||
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();
|
||||
},
|
||||
launch(){
|
||||
@@ -792,15 +809,18 @@
|
||||
this.updateLoadingBar();
|
||||
},
|
||||
updateLoadingBar(){
|
||||
this.$loader.css({
|
||||
'width':parseInt((100 * this.audio.buffered.end(0) / this.audio.duration), 10)+'%'
|
||||
});
|
||||
if( this.audio.buffered.end(0) < this.audio.duration ){
|
||||
// loop through this function until file is fully loaded
|
||||
var that = this;
|
||||
window.requestAnimationFrame(that.updateLoadingBar.bind(that));
|
||||
}else{
|
||||
//console.log('Audio fully loaded');
|
||||
// if (track.readyState === 4){
|
||||
if(track.buffered.length>0){
|
||||
this.$loader.css({
|
||||
'width':parseInt((100 * this.audio.buffered.end(0) / this.audio.duration), 10)+'%'
|
||||
});
|
||||
if( this.audio.buffered.end(0) < this.audio.duration ){
|
||||
// loop through this function until file is fully loaded
|
||||
var that = this;
|
||||
window.requestAnimationFrame(that.updateLoadingBar.bind(that));
|
||||
}else{
|
||||
//console.log('Audio fully loaded');
|
||||
}
|
||||
}
|
||||
},
|
||||
onCanplay(){
|
||||
|
||||
@@ -555,7 +555,8 @@
|
||||
.emmit('stop-shuffle')
|
||||
.openDocument({
|
||||
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;
|
||||
}
|
||||
@@ -759,6 +760,22 @@
|
||||
|
||||
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();
|
||||
},
|
||||
launch(){
|
||||
@@ -792,15 +809,18 @@
|
||||
this.updateLoadingBar();
|
||||
},
|
||||
updateLoadingBar(){
|
||||
this.$loader.css({
|
||||
'width':parseInt((100 * this.audio.buffered.end(0) / this.audio.duration), 10)+'%'
|
||||
});
|
||||
if( this.audio.buffered.end(0) < this.audio.duration ){
|
||||
// loop through this function until file is fully loaded
|
||||
var that = this;
|
||||
window.requestAnimationFrame(that.updateLoadingBar.bind(that));
|
||||
}else{
|
||||
//console.log('Audio fully loaded');
|
||||
// if (track.readyState === 4){
|
||||
if(track.buffered.length>0){
|
||||
this.$loader.css({
|
||||
'width':parseInt((100 * this.audio.buffered.end(0) / this.audio.duration), 10)+'%'
|
||||
});
|
||||
if( this.audio.buffered.end(0) < this.audio.duration ){
|
||||
// loop through this function until file is fully loaded
|
||||
var that = this;
|
||||
window.requestAnimationFrame(that.updateLoadingBar.bind(that));
|
||||
}else{
|
||||
//console.log('Audio fully loaded');
|
||||
}
|
||||
}
|
||||
},
|
||||
onCanplay(){
|
||||
|
||||
Reference in New Issue
Block a user