diff interfaces/horizontal-sliders.js @ 508:8d01d2bf4b8f Dev_main

Bug #1567: Updated rest of button based interfaces to follow AB playback controls.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Thu, 11 Feb 2016 14:22:30 +0000
parents cb348f6208b2
children df2d916fd9cf
line wrap: on
line diff
--- a/interfaces/horizontal-sliders.js	Thu Feb 11 14:16:09 2016 +0000
+++ b/interfaces/horizontal-sliders.js	Thu Feb 11 14:22:30 2016 +0000
@@ -263,11 +263,15 @@
 	this.play.textContent = "Loading...";
 	this.play.value = audioObject.id;
 	this.play.disabled = true;
+    this.play.setAttribute("playstate","ready");
 	this.play.onclick = function(event)
 	{
 		var id = Number(event.currentTarget.value);
 		//audioEngineContext.metric.sliderPlayed(id);
-		audioEngineContext.play(id);
+        if (event.currentTarget.getAttribute("playstate") == "ready")
+        {audioEngineContext.play(id);}
+        else if (event.currentTarget.getAttribute("playstate") == "playing")
+        {audioEngineContext.stop();}
 	};
 	this.resize = function(event)
 	{
@@ -288,6 +292,7 @@
     this.startPlayback = function()
     {
         // Called when playback has begun
+        this.play.setAttribute("playstate","playing");
         $(".track-slider").removeClass('track-slider-playing');
 		$(this.holder).addClass('track-slider-playing');
 		var outsideReference = document.getElementById('outside-reference');
@@ -298,6 +303,7 @@
     this.stopPlayback = function()
     {
         // Called when playback has stopped. This gets called even if playback never started!
+        this.play.setAttribute("playstate","ready");
         $(this.holder).removeClass('track-slider-playing');
     };
 	this.getValue = function()