comparison core.js @ 2019:fea5c4f14e16

Feature #1261: Enabled with new <metricEnabled> flag in specification XML. Returns <event> nodes with <testTime> and <bufferTime>
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Wed, 03 Jun 2015 11:12:29 +0100
parents 301acd614289
children 4a0bfa7bef24
comparison
equal deleted inserted replaced
2018:301acd614289 2019:fea5c4f14e16
560 this.bufferNode.stop(0); 560 this.bufferNode.stop(0);
561 this.bufferNode = undefined; 561 this.bufferNode = undefined;
562 this.metric.stopListening(audioEngineContext.timer.getTestTime()); 562 this.metric.stopListening(audioEngineContext.timer.getTestTime());
563 } 563 }
564 }; 564 };
565
566 this.getCurrentPosition = function() {
567 var time = audioEngineContext.timer.getTestTime();
568 if (this.bufferNode != undefined) {
569 if (this.bufferNode.loop == true) {
570 if (audioEngineContext.status == 1) {
571 return time%this.buffer.duration;
572 } else {
573 return 0;
574 }
575 } else {
576 if (this.metric.listenHold) {
577 return time - this.metric.listenStart;
578 } else {
579 return 0;
580 }
581 }
582 } else {
583 return 0;
584 }
585 };
565 586
566 this.constructTrack = function(url) { 587 this.constructTrack = function(url) {
567 var request = new XMLHttpRequest(); 588 var request = new XMLHttpRequest();
568 this.url = url; 589 this.url = url;
569 request.open('GET',url,true); 590 request.open('GET',url,true);
656 this.listenedTimer = 0; 677 this.listenedTimer = 0;
657 this.listenStart = 0; 678 this.listenStart = 0;
658 this.listenHold = false; 679 this.listenHold = false;
659 this.initialPosition = -1; 680 this.initialPosition = -1;
660 this.movementTracker = []; 681 this.movementTracker = [];
682 this.listenTracker =[];
661 this.wasListenedTo = false; 683 this.wasListenedTo = false;
662 this.wasMoved = false; 684 this.wasMoved = false;
663 this.hasComments = false; 685 this.hasComments = false;
664 this.parent = caller; 686 this.parent = caller;
665 687
681 if (this.listenHold == false) 703 if (this.listenHold == false)
682 { 704 {
683 this.wasListenedTo = true; 705 this.wasListenedTo = true;
684 this.listenStart = time; 706 this.listenStart = time;
685 this.listenHold = true; 707 this.listenHold = true;
708
709 var evnt = document.createElement('event');
710 var testTime = document.createElement('testTime');
711 testTime.setAttribute('start',time);
712 var bufferTime = document.createElement('bufferTime');
713 bufferTime.setAttribute('start',this.parent.getCurrentPosition());
714 evnt.appendChild(testTime);
715 evnt.appendChild(bufferTime);
716 this.listenTracker.push(evnt);
717
686 console.log('slider ' + this.parent.id + ' played (' + time + ')'); // DEBUG/SAFETY: show played slider id 718 console.log('slider ' + this.parent.id + ' played (' + time + ')'); // DEBUG/SAFETY: show played slider id
687 } 719 }
688 }; 720 };
689 721
690 this.stopListening = function(time) 722 this.stopListening = function(time)
691 { 723 {
692 if (this.listenHold == true) 724 if (this.listenHold == true)
693 { 725 {
694 this.listenedTimer += (time - this.listenStart); 726 var diff = time - this.listenStart;
727 this.listenedTimer += (diff);
695 this.listenStart = 0; 728 this.listenStart = 0;
696 this.listenHold = false; 729 this.listenHold = false;
730
731 var evnt = this.listenTracker[this.listenTracker.length-1];
732 var testTime = evnt.getElementsByTagName('testTime')[0];
733 var bufferTime = evnt.getElementsByTagName('bufferTime')[0];
734 testTime.setAttribute('stop',time);
735 bufferTime.setAttribute('stop',this.parent.getCurrentPosition());
736 console.log('slider ' + this.parent.id + ' played for (' + diff + ')'); // DEBUG/SAFETY: show played slider id
697 } 737 }
698 }; 738 };
699 } 739 }
700 740
701 function randomiseOrder(input) 741 function randomiseOrder(input)