changeset 527:df8df0f47b34

Playback now tracks for looped playback exactly.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Fri, 19 Feb 2016 11:22:47 +0000
parents 97b84a942aff
children 43bbe6112705
files core.js
diffstat 1 files changed, 5 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/core.js	Fri Feb 19 10:40:52 2016 +0000
+++ b/core.js	Fri Feb 19 11:22:47 2016 +0000
@@ -21,6 +21,8 @@
 
 // Add a prototype to the bufferSourceNode to reference to the audioObject holding it
 AudioBufferSourceNode.prototype.owner = undefined;
+// Add a prototype to the bufferSourceNode to hold when the object was given a play command
+AudioBufferSourceNode.prototype.playbackStartTime = undefined;
 // Add a prototype to the bufferNode to hold the desired LINEAR gain
 AudioBuffer.prototype.playbackGain = undefined;
 // Add a prototype to the bufferNode to hold the computed LUFS loudness
@@ -1319,6 +1321,7 @@
                  this.outputGain.gain.setValueAtTime(0.0,startTime);
             }
 			this.bufferNode.start(startTime);
+            this.bufferNode.playbackStartTime = startTime;
 		}
 	};
 	
@@ -1337,19 +1340,7 @@
 	this.getCurrentPosition = function() {
 		var time = audioEngineContext.timer.getTestTime();
 		if (this.bufferNode != undefined) {
-			if (this.bufferNode.loop == true) {
-				if (audioEngineContext.status  == 1) {
-					return (time-this.metric.listenStart)%this.buffer.buffer.duration;
-				} else {
-					return 0;
-				}
-			} else {
-				if (this.metric.listenHold) {
-					return time - this.metric.listenStart;
-				} else {
-					return 0;
-				}
-			}
+            return (time - this.bufferNode.playbackStartTime)%this.buffer.buffer.duration;
 		} else {
 			return 0;
 		}
@@ -2809,6 +2800,7 @@
 		this.stop = function() {
 			clearInterval(this.interval);
 			this.interval = undefined;
+            this.scrubberHead.style.left = '0px';
 			if (this.maxTime < 60) {
 				this.curTimeSpan.textContent = '0.00';
 			} else {