From 2102c30881bbb03f53b1ec31b5839c9225eb5e01 Mon Sep 17 00:00:00 2001 From: Gerrit Linnemann Date: Mon, 2 Nov 2015 15:23:16 +0100 Subject: [PATCH] ready4testing --- kitchenradio/app/radio.js | 38 +++-- .../node_modules/node-mplayer/.npmignore | 25 --- .../node_modules/node-mplayer/LICENSE | 21 --- .../node_modules/node-mplayer/README.md | 152 ----------------- .../node-mplayer/lib/node-mplayer.js | 161 ------------------ .../node_modules/node-mplayer/package.json | 34 ---- kitchenradio/npm-debug.log | 26 --- kitchenradio/package.json | 1 - 8 files changed, 22 insertions(+), 436 deletions(-) delete mode 100644 kitchenradio/node_modules/node-mplayer/.npmignore delete mode 100644 kitchenradio/node_modules/node-mplayer/LICENSE delete mode 100644 kitchenradio/node_modules/node-mplayer/README.md delete mode 100644 kitchenradio/node_modules/node-mplayer/lib/node-mplayer.js delete mode 100644 kitchenradio/node_modules/node-mplayer/package.json delete mode 100644 kitchenradio/npm-debug.log diff --git a/kitchenradio/app/radio.js b/kitchenradio/app/radio.js index 783e711..7e1e0d9 100644 --- a/kitchenradio/app/radio.js +++ b/kitchenradio/app/radio.js @@ -7,7 +7,7 @@ // load the things we need -var Mplayer = require('node-mplayer'); +//nothing yet var App = null; @@ -52,31 +52,37 @@ exports.getChannel = function(idx) { exports.play = function(idx) { var channel = Conf.channels[idx]; if(channel !== undefined) { - var stream2play; - - try { + var stream2play = channel.stream; + + /*try { var parsers = require("playlist-parser"); var M3U = parsers.M3U; - + var fs = require("fs"); var playlist = M3U.parse(fs.readFileSync('/Users/gerrit/Downloads/swr3_m.m3u', { encoding: "utf8" })); Log.inspect('Radio: playlist', playlist); - + if(Helper.isDefinedAndNotNull(playlist[0])) { stream2play = playlist[0].file; } } catch(e) { Log.error(e); - } - - - if(Helper.isDefinedAndNotNull(stream2play)) { - Log.debug('Radio: Load stream: ' + stream2play); - - player.setFile(stream2play); - player.play(); - } else { - Log.error('Radio: No stream defined!'); + }*/ + + + ls = childProcess.exec( + 'mplayer -slave -quiet -input file=' + , + function (error, stdout, stderr) { + Log.log('Radio: stdout: ' + stdout); + Log.log('Radio: stderr: ' + stderr); + if (error !== null) { + Log.error('Radio: exec error: ' + error); + } + }); + + ls.on('exit', function (code){ + Log.log('Radio: Child process exited with exit code ' + code); + }); } } else { Log.error('Radio: No channel defined!'); diff --git a/kitchenradio/node_modules/node-mplayer/.npmignore b/kitchenradio/node_modules/node-mplayer/.npmignore deleted file mode 100644 index da23d0d..0000000 --- a/kitchenradio/node_modules/node-mplayer/.npmignore +++ /dev/null @@ -1,25 +0,0 @@ -# Logs -logs -*.log - -# Runtime data -pids -*.pid -*.seed - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - -# Dependency directory -# Deployed apps should consider commenting this line out: -# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git -node_modules diff --git a/kitchenradio/node_modules/node-mplayer/LICENSE b/kitchenradio/node_modules/node-mplayer/LICENSE deleted file mode 100644 index 6eb6999..0000000 --- a/kitchenradio/node_modules/node-mplayer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Loïc Stankovic - -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. \ No newline at end of file diff --git a/kitchenradio/node_modules/node-mplayer/README.md b/kitchenradio/node_modules/node-mplayer/README.md deleted file mode 100644 index b051f98..0000000 --- a/kitchenradio/node_modules/node-mplayer/README.md +++ /dev/null @@ -1,152 +0,0 @@ -node-mplayer -============ - -A node.js wrapper for MPlayer on Linux. Use it to play music on your sound card! - -## Usage - -First, install the module with (assuming you already installed MPlayer) - - npm install node-mplayer - -Then, you need to make a new instance of the module. The constructor of the module can take the path of the file to play. - - var Mplayer = require('node-mplayer'); - - var player1 = new Mplayer('/home/node/Music/Kalimba.mp3'); - var player2 = new Mplayer(); - -## Available methods - -### play - -This method will play the file defined when the player object was instanciated or setted with `setFile()`. This method MUST be called before any other. -It can take in parameter an object that contains the volume and the number of times to play the file (see `setVolume` and `setLoop`). - - player.play(); - player.play({volume: 50}); - player.play({volume: 50, - loop: 10}); - -### checkPlaying - -This method indicates if the player is currently playing something. - - player.checkPlaying(); //returns true if playing, false if not - -### stop - -This method will stop the played file. - - player.stop(); - - -### quit - -This Method will close the underlying process - - player.quit(); - -### pause - -This one will toggle pause. - - player.pause(); - -### mute - -The method to toggle mute - - player.mute(); - -### setVolume - -This method is used to set the volume. It takes one parameter, the volume value that can go from 1 to 100. - - player.setVolume(52); //will set the volume to 52% - -### seek - -This method is used to navigate in the playing file. It take one parameter, the seek value in seconds that goes from 0 to the end of the file. This value is absolute. - - player.seek(50); //will go to 50 seconds - -### setLoop - -This will set the number of times to replay the file. The parameter is the number of times, -1 is forever. - - player.setLoop(20); //will play the file 20 times - -### setSpeed - -This will set the playing speed. It takes one parameter, the speed. 1 is the default speed. - - player.setSpeed(0.5); //will play the file 0.5x slower - player.setSpeed(20); //will play the file 20x faster - -### setFile - -This one is used to set the file to play. The changes will take effect after calling the `play()` method. It takes the path of the file in parameter. - - player.setFile('/home/node/Music/asdf.mp3'); - -### getTimeLength - -Returns the length of the file in seconds. It needs a callback. - - player.getTimeLength(function(length){ - console.log(length); - }); - -### getTimePosition - -Returns the elapsed play time in seconds. It needs a callback. - - player.getTimePosition(function(elapsedTime){ - console.log(elapsedTime); - }); - -### getPercentPosition - -Return the elapsed time in percent. It needs a callback. - - player.getPercentPosition(function(elapsedPercent){ - console.log(elapsedPercent); - }); - - -### getVolume - -Return the current volume. It needs a callback. - - player.getVolume(function(currentVolume){ - console.log(currentVolume); - }); - -##Events - -### end - -The end event is emitted when the file has ended. - -### error - -The error event is emitted when an error has ocurred. - -## Stability - -This module uses the [`readline`](http://www.nodejs.org/api/readline.html) module, which is currently marked unstable. - -This module has been tested on Ubuntu 14.04 LTS with MPlayer 1.1-4.8 and on Ubuntu 15.04 with MPlayer2 2.0-728-g2c378c7-4. - -## Contributing - -Any contribution is welcome! Just create a pull request, and I'll take a look as soon as possible. - -## Credits - -Here's a list of people who contributed to this project : - -* [Maocx](https://github.com/Maocx) -* [lacrioque](https://github.com/lacrioque) -* [nkcr](https://github.com/nkcr) \ No newline at end of file diff --git a/kitchenradio/node_modules/node-mplayer/lib/node-mplayer.js b/kitchenradio/node_modules/node-mplayer/lib/node-mplayer.js deleted file mode 100644 index f848db6..0000000 --- a/kitchenradio/node_modules/node-mplayer/lib/node-mplayer.js +++ /dev/null @@ -1,161 +0,0 @@ -/*globals require, module*/ -var cp = require('child_process'), - events = require('events'), - fs = require('fs'), - readline = require('readline'), - spawn = cp.spawn; - -function Mplayer(path){ - this.childProc = null; - this.file = ""; - this.rl = null; - this.playing = false; - this.volume = 100; - if(typeof path !== 'undefined') - this.setFile(path); - - events.EventEmitter.call(this); - - cp.exec('mplayer', function(err, stdout, stdin){ - if(err) - throw new Error("Mplayer encountered an error or isn't installed."); - }); -} - -Object.setPrototypeOf(Mplayer.prototype, events.EventEmitter.prototype); - -Mplayer.prototype.play = function(opts) { - if(this.file !== null){ - if(opts && opts.volume) - this.volume = opts.volume; - var args = ['-slave', '-quiet', '--volume='+this.volume, this.file], - that = this; - - this.childProc = spawn('mplayer', args); - this.playing = true; - - if(opts && opts.loop) - this.setLoop(opts.loop); - - this.childProc.on('error', function(error){ - that.emit('error'); - }); - - this.childProc.on('exit', function(code, sig){ - if(code === 0 && sig === null){ - that.playing = false; - that.emit('end'); - } - }); - - this.rl = readline.createInterface({ - input: this.childProc.stdout, - output: this.childProc.stdin - }); - } -}; - -Mplayer.prototype.checkPlaying = function(){ - return this.playing; -}; - -Mplayer.prototype.quit = function() { - if(this.childProc !== null){ - this.playing = false; - this.childProc.stdin.write('quit\n'); - } -}; - -Mplayer.prototype.getPercentPosition = function(callback) { - if(this.childProc !== null){ - this.rl.question("get_percent_pos\n", function(answer) { - callback(answer.split('=')[1]); - }); - } -}; - -Mplayer.prototype.stop = function() { - if(this.childProc !== null){ - this.childProc.stdin.write('stop\n'); - this.playing = false; - } -}; - - -Mplayer.prototype.pause = function() { - if(this.childProc !== null){ - this.childProc.stdin.write('pause\n'); - } -}; - -Mplayer.prototype.mute = function() { - if(this.childProc !== null){ - this.childProc.stdin.write('mute\n'); - } -}; - -Mplayer.prototype.setVolume = function(volume) { - if(this.childProc !== null){ - this.volume = volume; - this.childProc.stdin.write('volume ' + volume + ' 1\n'); - } -}; - -Mplayer.prototype.seek = function(sec) { - if(this.childProc !== null){ - this.childProc.stdin.write('seek ' + sec + ' 2\n'); - } -}; - -Mplayer.prototype.setLoop = function(times) { - if(this.childProc !== null){ - this.childProc.stdin.write('loop ' + times + '\n'); - } -}; - -Mplayer.prototype.setSpeed = function(speed) { - if(this.childProc !== null){ - this.childProc.stdin.write('speed_set ' + speed + '\n'); - } -}; - -Mplayer.prototype.setFile = function(path) { - if(this.childProc){ - this.quit(); - } - if(fs.existsSync(path)) - this.file = path; - else - throw new Error("File '" + path + "' not found!"); -}; - -Mplayer.prototype.getTimeLength = function(callback) { - if(this.childProc !== null){ - this.rl.question("get_time_length\n", function(answer) { - callback(answer.split('=')[1]); - }); - } -}; - -Mplayer.prototype.getTimePosition = function(callback) { - if(this.childProc !== null){ - var that = this; - this.rl.question("get_time_pos\n", function(answer) { - var splittedAns = answer.split('='); - - if (splittedAns[0]=='ANS_TIME_POSITION'){ - callback(splittedAns[1]); - } - else{ - // Try again :( - that.getTimePosition(callback); - } - }); - } -}; - -Mplayer.prototype.getVolume = function(callback) { - return callback(this.volume); -} - -module.exports = Mplayer; \ No newline at end of file diff --git a/kitchenradio/node_modules/node-mplayer/package.json b/kitchenradio/node_modules/node-mplayer/package.json deleted file mode 100644 index 65e255f..0000000 --- a/kitchenradio/node_modules/node-mplayer/package.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "node-mplayer", - "version": "0.0.5", - "description": "Node.js wrapper for mplayer on linux.", - "main": "./lib/node-mplayer.js", - "repository": { - "type": "git", - "url": "https://github.com/loics2/node-mplayer.git" - }, - "keywords": [ - "mplayer", - "wrapper", - "music", - "player", - "sound", - "media" - ], - "author": { - "name": "Loïc Stankovic" - }, - "license": "MIT", - "readme": "node-mplayer\n============\n\nA node.js wrapper for MPlayer on Linux. Use it to play music on your sound card!\n\n## Usage\n\nFirst, install the module with (assuming you already installed MPlayer)\n\n npm install node-mplayer\n\nThen, you need to make a new instance of the module. The constructor of the module can take the path of the file to play. \n\n var Mplayer = require('node-mplayer'); \n \n var player1 = new Mplayer('/home/node/Music/Kalimba.mp3');\n var player2 = new Mplayer();\n \n## Available methods\n\n### play\n\nThis method will play the file defined when the player object was instanciated or setted with `setFile()`. This method MUST be called before any other. \nIt can take in parameter an object that contains the volume and the number of times to play the file (see `setVolume` and `setLoop`).\n\n player.play();\n player.play({volume: 50});\n player.play({volume: 50,\n loop: 10});\n\n### checkPlaying\n\nThis method indicates if the player is currently playing something.\n\n player.checkPlaying(); //returns true if playing, false if not\n\n### stop\n\nThis method will stop the played file. \n\n player.stop();\n\n\n### quit\n\nThis Method will close the underlying process\n\n player.quit();\n \n### pause\n\nThis one will toggle pause.\n\n player.pause();\n \n### mute\n\nThe method to toggle mute\n\n player.mute();\n \n### setVolume\n\nThis method is used to set the volume. It takes one parameter, the volume value that can go from 1 to 100.\n\n player.setVolume(52); //will set the volume to 52%\n\n### seek\n\nThis method is used to navigate in the playing file. It take one parameter, the seek value in seconds that goes from 0 to the end of the file. This value is absolute.\n\n player.seek(50); //will go to 50 seconds\n\n### setLoop\n\nThis will set the number of times to replay the file. The parameter is the number of times, -1 is forever.\n\n player.setLoop(20); //will play the file 20 times\n \n### setSpeed\n\nThis will set the playing speed. It takes one parameter, the speed. 1 is the default speed.\n\n player.setSpeed(0.5); //will play the file 0.5x slower\n player.setSpeed(20); //will play the file 20x faster\n \n### setFile\n\nThis one is used to set the file to play. The changes will take effect after calling the `play()` method. It takes the path of the file in parameter.\n\n player.setFile('/home/node/Music/asdf.mp3');\n\n### getTimeLength\n\nReturns the length of the file in seconds. It needs a callback.\n\n player.getTimeLength(function(length){\n console.log(length);\n });\n\n### getTimePosition\n\nReturns the elapsed play time in seconds. It needs a callback.\n\n player.getTimePosition(function(elapsedTime){\n console.log(elapsedTime);\n });\n\n### getPercentPosition\n\nReturn the elapsed time in percent. It needs a callback.\n\n player.getPercentPosition(function(elapsedPercent){\n console.log(elapsedPercent);\n });\n\n\n### getVolume\n\nReturn the current volume. It needs a callback.\n\n player.getVolume(function(currentVolume){\n console.log(currentVolume);\n });\n\n##Events\n\n### end\n\nThe end event is emitted when the file has ended.\n\n### error\n\nThe error event is emitted when an error has ocurred.\n\n## Stability\n\nThis module uses the [`readline`](http://www.nodejs.org/api/readline.html) module, which is currently marked unstable. \n\nThis module has been tested on Ubuntu 14.04 LTS with MPlayer 1.1-4.8 and on Ubuntu 15.04 with MPlayer2 2.0-728-g2c378c7-4.\n\n## Contributing\n\nAny contribution is welcome! Just create a pull request, and I'll take a look as soon as possible.\n\n## Credits\n\nHere's a list of people who contributed to this project :\n\n* [Maocx](https://github.com/Maocx)\n* [lacrioque](https://github.com/lacrioque)\n* [nkcr](https://github.com/nkcr)", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/loics2/node-mplayer/issues" - }, - "homepage": "https://github.com/loics2/node-mplayer", - "_id": "node-mplayer@0.0.5", - "dist": { - "shasum": "fb7a7d950199f61dff0c905e06b0c67d8a6cbc11" - }, - "_from": "node-mplayer@*", - "_resolved": "https://registry.npmjs.org/node-mplayer/-/node-mplayer-0.0.5.tgz" -} diff --git a/kitchenradio/npm-debug.log b/kitchenradio/npm-debug.log deleted file mode 100644 index c633ce8..0000000 --- a/kitchenradio/npm-debug.log +++ /dev/null @@ -1,26 +0,0 @@ -0 info it worked if it ends with ok -1 verbose cli [ 'node', '/usr/local/bin/npm', 'start' ] -2 info using npm@1.4.3 -3 info using node@v0.10.26 -4 verbose run-script [ 'prestart', 'start', 'poststart' ] -5 info prestart kitchenradio@0.0.1 -6 info start kitchenradio@0.0.1 -7 verbose unsafe-perm in lifecycle true -8 info kitchenradio@0.0.1 Failed to exec start script -9 error kitchenradio@0.0.1 start: `node ./bin/www` -9 error Exit status 8 -10 error Failed at the kitchenradio@0.0.1 start script. -10 error This is most likely a problem with the kitchenradio package, -10 error not with npm itself. -10 error Tell the author that this fails on your system: -10 error node ./bin/www -10 error You can get their info via: -10 error npm owner ls kitchenradio -10 error There is likely additional logging output above. -11 error System Darwin 14.5.0 -12 error command "node" "/usr/local/bin/npm" "start" -13 error cwd /Users/gerrit/Documents/node.js Projekte/KitchenRadio/kitchenradio -14 error node -v v0.10.26 -15 error npm -v 1.4.3 -16 error code ELIFECYCLE -17 verbose exit [ 1, true ] diff --git a/kitchenradio/package.json b/kitchenradio/package.json index b3b1c23..9ac57be 100644 --- a/kitchenradio/package.json +++ b/kitchenradio/package.json @@ -17,7 +17,6 @@ "dateformat": "*", "eyespect": "*", "interface-addresses": "*", - "node-mplayer": "*", "playlist-parser": "*" } } \ No newline at end of file