comparison core.js @ 896:ce1f952a36f3

Fixed listen tracker for non-looping audioElements reporting start and stop were time 0
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Thu, 11 Jun 2015 09:45:52 +0100
parents e2e39f867db3
children b7f262db9886
comparison
equal deleted inserted replaced
895:e2e39f867db3 896:ce1f952a36f3
816 this.bufferNode.connect(this.outputGain); 816 this.bufferNode.connect(this.outputGain);
817 this.bufferNode.buffer = this.buffer; 817 this.bufferNode.buffer = this.buffer;
818 this.bufferNode.loop = audioEngineContext.loopPlayback; 818 this.bufferNode.loop = audioEngineContext.loopPlayback;
819 this.bufferNode.onended = function() { 819 this.bufferNode.onended = function() {
820 // Safari does not like using 'this' to reference the calling object! 820 // Safari does not like using 'this' to reference the calling object!
821 event.srcElement.owner.metric.stopListening(audioEngineContext.timer.getTestTime()); 821 event.srcElement.owner.metric.stopListening(audioEngineContext.timer.getTestTime(),event.srcElement.owner.getCurrentPosition());
822 }; 822 };
823 if (this.bufferNode.loop == false) { 823 if (this.bufferNode.loop == false) {
824 this.metric.startListening(audioEngineContext.timer.getTestTime()); 824 this.metric.startListening(audioEngineContext.timer.getTestTime());
825 } 825 }
826 this.bufferNode.start(startTime); 826 this.bufferNode.start(startTime);
828 }; 828 };
829 829
830 this.stop = function() { 830 this.stop = function() {
831 if (this.bufferNode != undefined) 831 if (this.bufferNode != undefined)
832 { 832 {
833 this.metric.stopListening(audioEngineContext.timer.getTestTime(),this.getCurrentPosition());
833 this.bufferNode.stop(0); 834 this.bufferNode.stop(0);
834 this.bufferNode = undefined; 835 this.bufferNode = undefined;
835 this.metric.stopListening(audioEngineContext.timer.getTestTime());
836 } 836 }
837 }; 837 };
838 838
839 this.getCurrentPosition = function() { 839 this.getCurrentPosition = function() {
840 var time = audioEngineContext.timer.getTestTime(); 840 var time = audioEngineContext.timer.getTestTime();
999 999
1000 console.log('slider ' + this.parent.id + ' played (' + time + ')'); // DEBUG/SAFETY: show played slider id 1000 console.log('slider ' + this.parent.id + ' played (' + time + ')'); // DEBUG/SAFETY: show played slider id
1001 } 1001 }
1002 }; 1002 };
1003 1003
1004 this.stopListening = function(time) 1004 this.stopListening = function(time,bufferStopTime)
1005 { 1005 {
1006 if (this.listenHold == true) 1006 if (this.listenHold == true)
1007 { 1007 {
1008 var diff = time - this.listenStart; 1008 var diff = time - this.listenStart;
1009 this.listenedTimer += (diff); 1009 this.listenedTimer += (diff);
1012 1012
1013 var evnt = this.listenTracker[this.listenTracker.length-1]; 1013 var evnt = this.listenTracker[this.listenTracker.length-1];
1014 var testTime = evnt.getElementsByTagName('testTime')[0]; 1014 var testTime = evnt.getElementsByTagName('testTime')[0];
1015 var bufferTime = evnt.getElementsByTagName('bufferTime')[0]; 1015 var bufferTime = evnt.getElementsByTagName('bufferTime')[0];
1016 testTime.setAttribute('stop',time); 1016 testTime.setAttribute('stop',time);
1017 bufferTime.setAttribute('stop',this.parent.getCurrentPosition()); 1017 if (bufferStopTime == undefined) {
1018 bufferTime.setAttribute('stop',this.parent.getCurrentPosition());
1019 } else {
1020 bufferTime.setAttribute('stop',bufferStopTime);
1021 }
1018 console.log('slider ' + this.parent.id + ' played for (' + diff + ')'); // DEBUG/SAFETY: show played slider id 1022 console.log('slider ' + this.parent.id + ' played for (' + diff + ')'); // DEBUG/SAFETY: show played slider id
1019 } 1023 }
1020 }; 1024 };
1021 1025
1022 this.exportXMLDOM = function() { 1026 this.exportXMLDOM = function() {