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
- Signal names can be anything of your choice.
- The signal array MUST be the same for both the transmitter and the receiver.
- Currently, a max of 13 signals are supported.
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!
- Media controls
- Games - remote controlled, multi-player
- Slideshows
- Pranks
- Malware
- Interesting browser extensions
- Increase the number of supported signals
- Cross-browser fixes
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).
- The mic is very bad at 'listening to' some random frequencies (even loud audible frequencies). This may be resonance and / or interference from the computer parts.
- As the frequency crosses 15khz, the amplitude decreases in a proportionate manner - the range decreases as a result.
- Frequency bleeding and interference is rampant. This can be avoided by keeping a significant gap between the bit-frequencies. Because of problem no. 2, using higher frequencies is almost impossible.
- Surprisingly, interference from a normal work / home background environment is very rare.
- The bitrate has to be very low. If you try to increase it, you lose accuracy in frequency detection.
- I used ASCII 'symbols' for higher bandwidth. Using binary 'symbols' binary files can be transferred more reliably, but the bandwidth would be waaay lower.
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.