From f1fa1a913aeb5eb8d359f9e216c797c7963e6afc Mon Sep 17 00:00:00 2001 From: Bram van der Veen <96aa48@gmail.com> Date: Fri, 5 Jun 2015 15:02:28 +0200 Subject: [PATCH] Added play command and streaming --- app.js | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/app.js b/app.js index 2b273e8..d287681 100644 --- a/app.js +++ b/app.js @@ -3,30 +3,40 @@ var lame = require('lame'); var mumble = require('mumble'); -mumble.connect('mumble://wallpiece:9648', function( error, client ) { - if( error ) { throw new Error( error ); } +mumble.connect('mumble://wallpiece:9648', function(error, client) { + if(error) { throw new Error(error); } client.authenticate('MusicBot', 'yolo'); - client.on( 'initialized', function() { - start( client ); + client.on('initialized', function () { + start(client); }); }); var start = function( client ) { - // client.outputStream().pipe(client.inputStream()); var input = client.inputStream(); var decoder = new lame.Decoder(); - var stream; - decoder.on( 'format', function( format ) { - console.log( format ); + client.channelByName('Gaming').join() - stream.pipe( client.inputStream({ - channels: format.channels, - sampleRate: format.sampleRate, - gain: 1 - })); + client.on('textMessage', function (data) { + // console.log(client.userBySession(data.session[0])); + if (data.message == 'play') { + 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 ); };