Mercurial > hg > webaudioevaluationtool
changeset 897:b7f262db9886
Feature #1246: Scrubber bar included. Not interactive yet
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Thu, 11 Jun 2015 10:06:58 +0100 |
parents | ce1f952a36f3 |
children | 070a90d1117c |
files | core.js example_eval/project.xml |
diffstat | 2 files changed, 30 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/core.js Thu Jun 11 09:45:52 2015 +0100 +++ b/core.js Thu Jun 11 10:06:58 2015 +0100 @@ -688,7 +688,11 @@ } } if (this.status== 1) { - if (id == undefined) {id = -1;} + if (id == undefined) { + id = -1; + } else { + interfaceContext.playhead.setTimePerPixel(this.audioObjects[id]); + } if (this.loopPlayback) { for (var i=0; i<this.audioObjects.length; i++) { @@ -711,6 +715,7 @@ } } } + interfaceContext.playhead.start(); } }; @@ -721,6 +726,7 @@ { this.audioObjects[i].stop(); } + interfaceContext.playhead.stop(); this.status = 0; } }; @@ -1699,23 +1705,27 @@ this.timePerPixel = 0; this.maxTime = 0; - this.startPlay = function(maxTime) { + this.playbackObject; + + this.setTimePerPixel = function(audioObject) { //maxTime must be in seconds + this.playbackObject = audioObject; + this.maxTime = audioObject.buffer.duration; var width = 490; //500 - 10, 5 each side of the tracker head - this.timePerPixel = maxTime/490; - this.maxTime = maxTime; - if (maxTime < 60) { + this.timePerPixel = this.maxTime/490; + if (this.maxTime < 60) { this.curTimeSpan.textContent = '0.00'; } else { this.curTimeSpan.textContent = '00:00'; } }; - this.update = function(time) { + this.update = function() { // Update the playhead position, startPlay must be called if (this.timePerPixel > 0) { + var time = this.playbackObject.getCurrentPosition(); var width = 490; - var pix = Math.floor(width*time); + var pix = Math.floor(time/this.timePerPixel); this.scrubberHead.style.left = pix+'px'; if (this.maxTime > 60.0) { var secs = time%60; @@ -1730,6 +1740,18 @@ } } }; + + this.interval = undefined; + + this.start = function() { + if (this.playbackObject != undefined && this.interval == undefined) { + this.interval = setInterval(function(){interfaceContext.playhead.update();},100); + } + }; + this.stop = function() { + clearInterval(this.interval); + this.interval = undefined; + }; }; }
--- a/example_eval/project.xml Thu Jun 11 09:45:52 2015 +0100 +++ b/example_eval/project.xml Thu Jun 11 10:06:58 2015 +0100 @@ -35,7 +35,7 @@ <metricEnable>elementListenTracker</metricEnable> </Metric> </setup> - <audioHolder id='0' hostURL="example_eval/" sampleRate="44100" randomiseOrder='true' repeatCount='0' loop='false' elementComments='true'> + <audioHolder id='0' hostURL="example_eval/" sampleRate="44100" randomiseOrder='true' repeatCount='0' loop='true' elementComments='true'> <interface> <title>Example Test Question</title> <scale position="0">Min</scale>