Remote control for Web apps
Remote.js is a library for developing remote controlled web apps. It is wireless and does not require additional hardware - it works via audio frequencies.
Note: Apps tested on Google Chrome only. If the examples don't work, try restarting the browser.
Once the apps are loaded, point the remote at the demo, and press the buttons.
To develop a remote controlled web app using Remote.js, you will need to create a transmitter (remote controller) and a receiver (the web app). The app listens for 'signals' from the transmitter and executes JavaScript code programmed by you, when it receives them.
Include remote.transmitter.js in the transmitter app's HTML page. Once included, you can create a transmitter as shown in this example.
var signals = ['cat', 'HIDE CONTENT', 'github'];
var t = Remote.transmitter(signals);
// ideally, signals would be emitted when buttons are clicked
document.querySelector('#cat-button').addEventListener('click', function() {
t.emit('cat');
});
document.querySelector('#github-button').addEventListener('click', function() {
t.emit('github');
});
// signals can be emitted any way you like, though
setTimeout(function() {
t.emit('foo');
}, 5000);
NOTE
Include remote.receiver.js in the receiver app's HTML page. Once included, you can create a receiver as shown in this example.
var signals = ['cat', 'HIDE CONTENT', 'foo'];
var r = Remote.receiver(signals);
r.on('cat', function(error, signal) {
if (!error) alert('Cats are mini-Tigers!');
});
r.on('HIDE CONTENT', function(error, signal) {
document.querySelector('#content').style.display = 'none';
});
r.on('github', function(error, signal) {
window.open('https://github.com');
});
What the signal can do is entirely upto you, the developer. Anything you can do with JavaScript, a valid signal can trigger it. Let your imaginations run wild!
I set out to create a wireless data transfer medium using acoustic frequencies, but faced some challenges because of which I paused worked on it, and instead created Remote.js out of the work done so far.
The following are some interesting points from my experiment.
Equipment used: Web Audio API, Nexus 5 (transmitter), MacBook Pro (receiver).
Copyright (c) 2014 Hage Yaapa <http://www.hacksparrow.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.