diff interfaces/discrete.js @ 1377:a03b04ea3357

Bug #1567: Updated rest of button based interfaces to follow AB playback controls.
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Thu, 11 Feb 2016 14:22:30 +0000
parents c277da1e89ca
children f0c74260c47d
line wrap: on
line diff
--- a/interfaces/discrete.js	Thu Feb 11 14:16:09 2016 +0000
+++ b/interfaces/discrete.js	Thu Feb 11 14:22:30 2016 +0000
@@ -275,11 +275,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)
 	{
@@ -323,6 +327,7 @@
     this.startPlayback = function()
     {
         // Called by audioObject when playback begins
+        this.play.setAttribute("playstate","playing");
         $(".track-slider").removeClass('track-slider-playing');
 		$(this.holder).addClass('track-slider-playing');
 		var outsideReference = document.getElementById('outside-reference');
@@ -334,6 +339,7 @@
     this.stopPlayback = function()
     {
         // Called by audioObject when playback stops
+        this.play.setAttribute("playstate","ready");
         $(this.holder).removeClass('track-slider-playing');
         this.play.textContent = "Play";
     }