Mercurial > hg > webaudioevaluationtool
comparison core.js @ 1617:ed5b4a9b266a
Possible fix for Bug #1238. audioObject metric collection now controlled by the audioObjects themselves for timer information. Lastclicked and sliderPlayed functions no longer used.
author | Nicholas Jillings <nickjillings@users.noreply.github.com> |
---|---|
date | Sun, 24 May 2015 11:33:04 +0100 |
parents | 4f3ddd805ff3 |
children | 05e7edb032b9 |
comparison
equal
deleted
inserted
replaced
1616:057ca7c45055 | 1617:ed5b4a9b266a |
---|---|
173 // When stopeed, the buffer node is deleted and recreated with the stored buffer. | 173 // When stopeed, the buffer node is deleted and recreated with the stored buffer. |
174 this.buffer; | 174 this.buffer; |
175 | 175 |
176 this.play = function(startTime) { | 176 this.play = function(startTime) { |
177 this.bufferNode = audioContext.createBufferSource(); | 177 this.bufferNode = audioContext.createBufferSource(); |
178 this.bufferNode.owner = this; | |
178 this.bufferNode.connect(this.outputGain); | 179 this.bufferNode.connect(this.outputGain); |
179 this.bufferNode.buffer = this.buffer; | 180 this.bufferNode.buffer = this.buffer; |
180 this.bufferNode.loop = audioEngineContext.loopPlayback; | 181 this.bufferNode.loop = audioEngineContext.loopPlayback; |
182 if (this.bufferNode.loop == false) { | |
183 this.bufferNode.onended = function() { | |
184 this.owner.metric.listening(audioEngineContext.timer.getTestTime()); | |
185 } | |
186 } | |
187 this.metric.listening(audioEngineContext.timer.getTestTime()); | |
181 this.bufferNode.start(startTime); | 188 this.bufferNode.start(startTime); |
182 this.played = true; | 189 this.played = true; |
183 }; | 190 }; |
184 | 191 |
185 this.stop = function() { | 192 this.stop = function() { |
186 if (this.bufferNode != undefined) | 193 if (this.bufferNode != undefined) |
187 { | 194 { |
188 this.bufferNode.stop(0); | 195 this.bufferNode.stop(0); |
189 this.bufferNode = undefined; | 196 this.bufferNode = undefined; |
197 this.metric.listening(audioEngineContext.timer.getTestTime()); | |
190 } | 198 } |
191 }; | 199 }; |
192 | 200 |
193 this.constructTrack = function(url) { | 201 this.constructTrack = function(url) { |
194 var request = new XMLHttpRequest(); | 202 var request = new XMLHttpRequest(); |
276 * Used only inside the audioObjects object. | 284 * Used only inside the audioObjects object. |
277 */ | 285 */ |
278 | 286 |
279 this.listenedTimer = 0; | 287 this.listenedTimer = 0; |
280 this.listenStart = 0; | 288 this.listenStart = 0; |
289 this.listenHold = false; | |
281 this.initialPosition = -1; | 290 this.initialPosition = -1; |
282 this.movementTracker = []; | 291 this.movementTracker = []; |
283 this.wasListenedTo = false; | 292 this.wasListenedTo = false; |
284 this.wasMoved = false; | 293 this.wasMoved = false; |
285 this.hasComments = false; | 294 this.hasComments = false; |
297 this.movementTracker[this.movementTracker.length] = [time, position]; | 306 this.movementTracker[this.movementTracker.length] = [time, position]; |
298 }; | 307 }; |
299 | 308 |
300 this.listening = function(time) | 309 this.listening = function(time) |
301 { | 310 { |
302 if (this.listenStart == 0) | 311 if (this.listenHold == false) |
303 { | 312 { |
304 this.wasListenedTo = true; | 313 this.wasListenedTo = true; |
305 this.listenStart = time; | 314 this.listenStart = time; |
315 this.listenHold = true; | |
306 } else { | 316 } else { |
307 this.listenedTimer += (time - this.listenStart); | 317 this.listenedTimer += (time - this.listenStart); |
308 this.listenStart = 0; | 318 this.listenStart = 0; |
319 this.listenHold = false; | |
309 } | 320 } |
310 }; | 321 }; |
311 } | 322 } |
312 | 323 |
313 function randomiseOrder(input) | 324 function randomiseOrder(input) |