Commits

sunhaitao  committed dba5025

Fixed some outdated contents in documents. Updated demos to compate with recent versions of Firefox. Added a demo to the Asynchronous API.

  • Participants
  • Parent commits c7ab526

Comments (0)

Files changed (4)

File DemoPages/reflector-asyn.htm

+<!DOCTYPE html>
+<html>
+<head>
+<title>Reflector (via Asynchronous API)</title>
+<style>
+canvas {
+	background:black;
+}
+#source {
+	/* -moz-transform: matrix(1, -0.1, 0, 1, 0, -30px); */
+}
+</style>
+</head>
+<body>
+<div id="source">
+<div><canvas width="640" height="100" id="audioMonitor"></canvas></div>
+<div><canvas width='640' height='480' id='videoMonitor'></canvas></div>
+<script>
+//<![CDATA[
+if (navigator.conductor) {
+	function $(id) {return document.getElementById(id)}
+
+	function AudioMonitor(canvas, style) {
+		var mCanvas = canvas;
+		var mContext = mCanvas.getContext('2d');
+		var mCanvasWidth = mCanvas.width;
+		var mCanvasHeight = mCanvas.height
+		mContext.strokeStyle = style;
+		mContext.fillStyle = style;
+		mContext.scale(1, mCanvasHeight / 65535);
+		mContext.translate(0, 32767);
+		var bufferSize = null;
+		this.drawPulses = function (data) {
+			if (bufferSize == null) {
+				bufferSize = data.length;
+				mContext.scale(mCanvasWidth / (bufferSize - 1), 1);
+			}
+			mContext.clearRect(0, -32768, bufferSize, 65535);
+			mContext.beginPath();
+			mContext.moveTo(0, 0);
+			for (var x = 0; x < data.length; x += 1) {
+				mContext.lineTo(x, - data[x]);
+			}
+			mContext.lineTo(bufferSize, 0);
+			mContext.lineTo(bufferSize, 32767);
+			mContext.lineTo(0, 32767);
+			mContext.lineTo(0, 0);
+			mContext.closePath();
+			mContext.fill();
+		}
+	}
+
+	navigator.conductor.book(
+		{protocol:"http://devtaste.com/extras/conductor/specs/audio-input", optional:false},
+		{
+			anyOf:[
+				{protocol:"http://devtaste.com/extras/conductor/specs/video-input"},
+				{protocol:"http://devtaste.com/extras/conductor/specs/audio-input"},
+			],
+			"optional":true
+		},
+		function (micReserve, camReserve) {
+			if (micReserve !== undefined) {
+				var micHandle = micReserve.take({freq:22000});
+				var audioMonitor = new AudioMonitor($('audioMonitor'),"rgb(160, 250, 240)");
+			}
+
+			if (camReserve !== undefined) {
+				var videoMonitor = document.getElementById("videoMonitor");
+				var ctx = videoMonitor.getContext('2d');
+				var camHandle = camReserve.take();
+			}
+
+			window.mozRequestAnimationFrame(function step(timestamp) {
+				if (micHandle) {
+					micHandle.read(function (data) {
+						audioMonitor.drawPulses(data);
+					});
+				}
+				if (camHandle) {
+					camHandle.read(function (pImageData) {
+						pImageData.mozPutOn(ctx, 0, (videoMonitor.height - pImageData.height)/2);
+					});
+				}
+				window.mozRequestAnimationFrame(step);
+			});
+
+			window.onunload = function () {
+				if (micHandle) { micHandle.close(); }
+				if (camHandle) { camHandle.close(); }
+			}
+		}
+	);
+
+	document.writeln("Running since " + new Date());
+} else {
+	document.writeln("Conductor API support is required.");
+}
+
+//]]>
+</script>
+</div>
+</body>
+</html>
+

File DemoPages/reflector.htm

 <!DOCTYPE html>
 <html>
 <head>
+<title>Reflector (via Synchronous API)</title>
 <style>
 canvas {
 	background:black;
 				bufferSize = data.length;
 				mContext.scale(mCanvasWidth / (bufferSize - 1), 1);
 			}
-			//mContext.save();
 			mContext.clearRect(0, -32768, bufferSize, 65535);
 			mContext.beginPath();
 			mContext.moveTo(0, 0);
 			mContext.lineTo(0, 32767);
 			mContext.lineTo(0, 0);
 			mContext.closePath();
-			//mContext.stroke();
 			mContext.fill();
-			//mContext.restore();
 		}
 	}
 
 		var camHandle = camReserve.take();
 	}
 
-
-	window.addEventListener("MozBeforePaint", function step(event) {
+	window.mozRequestAnimationFrame(function step(timestamp) {
 		if (micHandle) {
 			micHandle.read(function (data) {
 				audioMonitor.drawPulses(data);
 				pImageData.mozPutOn(ctx, 0, (videoMonitor.height - pImageData.height)/2);
 			});
 		}
-		window.mozRequestAnimationFrame();
-	}, false);
-	window.mozRequestAnimationFrame();
+		window.mozRequestAnimationFrame(step);
+	});
 
 	window.onunload = function () {
 		if (micHandle) { micHandle.close(); }

File Documents/API.htm

 <html>
 <head>
 <meta charset="utf-8"/>
-<title>Device Master API</title>
+<title>Conductor API</title>
 <style>
 h1 {
 	font-family: Verdana, sans-serif;
 System Requirements and Capabilities
 ------------------------------------
 
-Currently, this extension supports x86 edition of Firefox 4, 5,
-6, 7 and 8 on WinNT and Linux.
+Currently, this extension supports x86 edition of Firefox 8, 9,
+10 and 11 on WinNT and Linux.
 
 The following types of device are supported:
  * Audio input device (via OpenAL)