Commit 455d8d37 authored by Karan Goel's avatar Karan Goel
Browse files

some more code - doesn't work

parent cde5c9c6
var tessel = require('tessel');
var fs = require('fs');
var http = require('http');
var audio = require('audio-vs1053b').use(tessel.port['A']);
var audioFile = 'sample.mp3';
// Wait for the module to connect
audio.on('ready', function() {
console.log("Audio module connected! Setting volume...");
// Set the volume in decibels. Around .8 is good; 80% max volume or -25db
audio.setVolume(.8, function(err) {
if (err) {
return console.log(err);
}
// Get the song
console.log('Retrieving file...');
var url = 'http://127.0.0.1:3000/proxy?url=https://soundcloud.com/monstercat/astronaut-champions-laslzo-remix';
var body = '';
http.get(url, function(res) {
console.log('Response received');
res.on('data', function(chunk) {
console.log('Downloading song...');
body += chunk;
});
res.on('end', function() {
// all data has been downloaded
console.log('Song has been downloaded');
audio.play(body, function(err) {
if (err) {
console.log(err);
} else {
console.log('Done playing');
}
});
});
});
});
});
// If there is an error, report it
audio.on('error', function(err) {
console.log(err);
});
......@@ -40,7 +40,7 @@
"homepage": "https://github.com/tessel/audio-vs1053b",
"_id": "audio-vs1053b@0.1.91",
"_shasum": "ffcfa58a984b5c5a45ede22c9d31269adf84a219",
"_from": "audio-vs1053b@^0.1.91",
"_from": "audio-vs1053b@>=0.1.91 <0.2.0",
"_npmVersion": "2.0.2",
"_nodeVersion": "0.10.29",
"_npmUser": {
......@@ -61,6 +61,5 @@
"shasum": "ffcfa58a984b5c5a45ede22c9d31269adf84a219",
"tarball": "http://registry.npmjs.org/audio-vs1053b/-/audio-vs1053b-0.1.91.tgz"
},
"_resolved": "https://registry.npmjs.org/audio-vs1053b/-/audio-vs1053b-0.1.91.tgz",
"readme": "ERROR: No README data found!"
"_resolved": "https://registry.npmjs.org/audio-vs1053b/-/audio-vs1053b-0.1.91.tgz"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment