changeset 507:fbba14d4e21c Dev_main

Bug #1567: AB.js interfaces, the playback toggle now controls both playback start and playback stop commands. Button text updated to reflect.
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Thu, 11 Feb 2016 14:16:09 +0000
parents 1dbc6d3e6fb5
children 8d01d2bf4b8f
files interfaces/AB.js
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/interfaces/AB.js	Thu Feb 11 14:07:24 2016 +0000
+++ b/interfaces/AB.js	Thu Feb 11 14:16:09 2016 +0000
@@ -218,10 +218,17 @@
 			}
 			console.log("Selected "+id+' ('+time+')');
 		};
+        this.playback.setAttribute("playstate","ready");
 		this.playback.onclick = function(event)
 		{
 			var id = event.currentTarget.parentElement.getAttribute('track-id');
-			audioEngineContext.play(id);
+            if (event.currentTarget.getAttribute("playstate") == "ready")
+            {
+                audioEngineContext.play(id);
+            } else if (event.currentTarget.getAttribute("playstate") == "playing") {
+                audioEngineContext.stop();
+            }
+			
 		};
 		
 		this.enable = function()
@@ -240,17 +247,19 @@
 				progress = progress.split('.')[0];
 				this.playback.textContent = progress+'%';
 			} else {
-				this.playback.textContent = "Listen";
+				this.playback.textContent = "Play";
 			}
 		};
         this.startPlayback = function()
         {
             $('.comparitor-button').text('Listen');
-            $(this.playback).text('Playing');
+            $(this.playback).text('Stop');
+            this.playback.setAttribute("playstate","playing");
         };
         this.stopPlayback = function()
         {
             $(this.playback).text('Listen');
+            this.playback.setAttribute("playstate","ready");
         };
 		this.exportXMLDOM = function(audioObject)
 		{