Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add a proper test page

  • Loading branch information...
commit 74a03d3fbcfd232d73d59895ecc53a9bffd712eb 1 parent f992515
@benvanik authored
Showing with 140 additions and 4 deletions.
  1. +1 −0  .npmignore
  2. +139 −0 apps/chrome/src/test.html
  3. +0 −4 lib/devicehandler.js
View
1  .npmignore
@@ -4,3 +4,4 @@ node_modules
.git/
.git*
apps/
+test/
View
139 apps/chrome/src/test.html
@@ -0,0 +1,139 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Trampoline Test Page</title>
+ <script src="base.js"></script>
+ <script src="service.js"></script>
+ <script src="device.js"></script>
+ <script>
+ var endpoint = 'http://localhost:8090';
+ var service = new Service(endpoint);
+
+ var deviceList;
+ var statusBox;
+ var seekBar;
+ var isSeeking = false;
+
+ var devices = {}; // deviceId -> Device mapping
+ var targetDevice = null;
+ var currentStatus = null;
+
+ function queryDevices() {
+ service.getDevices(function(response) {
+ if (!response) {
+ window.console.log('service not running, unable to query devices');
+ return;
+ }
+ for (var n = 0; n < response.devices.length; n++) {
+ var deviceInfo = response.devices[n];
+ if (!devices[deviceInfo.id]) {
+ var device = new Device(service, deviceInfo);
+ devices[deviceInfo.id] = device;
+ if (!targetDevice) {
+ targetDevice = device;
+ }
+
+ var option = document.createElement('option');
+ option.innerText =
+ device.id + ' / ' + device.name + ' / ' + device.deviceId;
+ deviceList.options.add(option);
+
+ window.console.log('new device:');
+ window.console.log(device);
+ }
+ }
+ // TODO: remove devices no longer present
+ });
+ }
+
+ function updateStatus() {
+ if (!targetDevice) {
+ return;
+ }
+
+ targetDevice.getStatus(function(status) {
+ currentStatus = status;
+ if (!status) {
+ return;
+ }
+
+ if (!isSeeking) {
+ seekBar.value = (status.position / status.duration) * 100;
+ }
+
+ // TODO: better presentation
+ statusBox.innerText = JSON.stringify(status);
+ });
+ }
+ window.setInterval(function() {
+ updateStatus();
+ }, 500);
+
+ function seek(percent) {
+ if (!currentStatus) {
+ return;
+ }
+
+ var position = (percent / 100) * currentStatus.duration;
+ targetDevice.scrub(position);
+ }
+
+ function rewind() {
+ seek(0);
+ }
+
+ function pause() {
+ targetDevice.rate(0);
+ }
+
+ function resume() {
+ targetDevice.rate(1);
+ }
+
+ function stop() {
+ targetDevice.stop();
+ }
+
+ function test1() {
+ var content = 'http://wwwappskc.lonestar.edu/cgi/video/html5/test.m4v';
+ //var content = 'http://10.0.1.3:8090/content/test';
+ targetDevice.play(content, 0);
+ }
+
+ window.addEventListener('load', function() {
+ deviceList = document.getElementById('deviceList');
+ statusBox = document.getElementById('statusBox');
+ seekBar = document.getElementById('seekBar');
+ seekBar.addEventListener('mousedown', function() {
+ isSeeking = true;
+ });
+ seekBar.addEventListener('mouseup', function() {
+ seek(parseInt(seekBar.value));
+ isSeeking = false;
+ });
+
+ var kDeviceRefreshInterval = 5 * 1000;
+ window.setInterval(queryDevices, kDeviceRefreshInterval);
+ queryDevices();
+ });
+
+ </script>
+ </head>
+ <body>
+ <select id="deviceList">
+ </select>
+ <br/>
+ <div id="statusBox">
+ [status]
+ </div>
+ <br/>
+ <input id="seekBar" type="range" min="0" max="100" value="0" step="1"/>
+ <br/>
+ <a href="javascript:rewind();">rewind</a>&nbsp;
+ <a href="javascript:resume();">resume</a>&nbsp;
+ <a href="javascript:pause();">pause</a>&nbsp;
+ <a href="javascript:stop();">stop</a>&nbsp;
+ <br/>
+ <a href="javascript:test1();">test1</a>&nbsp;
+ </body>
+</html>
View
4 lib/devicehandler.js
@@ -64,7 +64,3 @@ DeviceHandler.prototype.photo = function(req, callback) {
// TODO: implement photo
callback(res);
};
-
-DeviceHandler.prototype.test1 = function(req, callback) {
- this.device.play('http://10.0.1.3:8090/content/test', 0, callback);
-};
Please sign in to comment.
Something went wrong with that request. Please try again.