Added play command and streaming

This commit is contained in:
Bram van der Veen 2015-06-05 15:02:28 +02:00
parent eb365a2ab2
commit f1fa1a913a

38
app.js
View file

@ -3,30 +3,40 @@
var lame = require('lame'); var lame = require('lame');
var mumble = require('mumble'); var mumble = require('mumble');
mumble.connect('mumble://wallpiece:9648', function( error, client ) { mumble.connect('mumble://wallpiece:9648', function(error, client) {
if( error ) { throw new Error( error ); } if(error) { throw new Error(error); }
client.authenticate('MusicBot', 'yolo'); client.authenticate('MusicBot', 'yolo');
client.on( 'initialized', function() { client.on('initialized', function () {
start( client ); start(client);
}); });
}); });
var start = function( client ) { var start = function( client ) {
// client.outputStream().pipe(client.inputStream());
var input = client.inputStream(); var input = client.inputStream();
var decoder = new lame.Decoder(); var decoder = new lame.Decoder();
var stream; client.channelByName('Gaming').join()
decoder.on( 'format', function( format ) {
console.log( format );
stream.pipe( client.inputStream({ client.on('textMessage', function (data) {
channels: format.channels, // console.log(client.userBySession(data.session[0]));
sampleRate: format.sampleRate, if (data.message == 'play') {
gain: 1 var stream;
})); decoder.on( 'format', function( format ) {
// console.log( format );
stream.pipe( client.inputStream({
channels: format.channels,
sampleRate: format.sampleRate,
gain: 0.1
}));
});
stream = require('fs').createReadStream(__dirname + '/test.mp3').pipe( decoder );
}
client.channelByName('Gaming').join()
// if (data.)
// client.sendMessage('Received message');
}); });
stream = require('fs').createReadStream(__dirname + '/test.mp3').pipe( decoder );
}; };