├── .gitignore ├── README.md ├── bin └── index.js ├── lib ├── audiostream.js └── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Chromecast Unix Audio 2 | Uses `cvlc` to create an http stream of your local audio and sends it to the chromecast. 3 | 4 | ##Installation 5 | ```bash 6 | $ (sudo) npm install -g chromecast-unix-audio 7 | ``` 8 | 9 | Make sure you have the `cvlc` library installed on your preffered os, some examples: 10 | **Fedora** 11 | ```bash 12 | $ dnf install cvlc 13 | ``` 14 | 15 | **Ubuntu** 16 | ```bash 17 | $ apt-get install cvlc 18 | ``` 19 | 20 | ##Usage 21 | When installed globally just do: 22 | ``` 23 | $ chromecast-unix-audio # Stream started at: http://0.0.0.0:xxxx/pc.mp3 24 | ``` 25 | And it will automagically send it to a founded chromecast. 26 | 27 | ##Cons 28 | There is a delay of about 10 seconds. 29 | -------------------------------------------------------------------------------- /bin/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | module.exports = require('../lib'); 4 | -------------------------------------------------------------------------------- /lib/audiostream.js: -------------------------------------------------------------------------------- 1 | var sys = require('sys') 2 | var shell = require('shelljs'); 3 | var ip = require('ip'); 4 | 5 | var streamsettings = { 6 | adapter: "", 7 | port: "8123", 8 | mp3Path: "pc.mp3" 9 | } 10 | 11 | var audiostream = { 12 | start: function(){ 13 | this.getAudioAdapter() 14 | this.startStream() 15 | }, 16 | getAudioAdapter: function() { 17 | streamsettings.adapter = ((shell.exec("pactl list | grep \"Monitor Source\"", {silent:true}).output).replace("Monitor Source:", "")).replace(/\s/g, "") // Removes all spaces and only keeps the name 18 | }, 19 | startStream: function() { 20 | shell.exec("cvlc -vvv pulse://" + streamsettings.adapter + " --sout '#transcode{acodec=mp3,ab=128,channels=2}:standard{access=http,dst=0.0.0.0:" + streamsettings.port + "/" + streamsettings.mp3Path + "}'", {silent: true, async: true}).output 21 | console.log("Stream started at: " + this.returnIp()) 22 | }, 23 | returnIp: function() { 24 | return "http://" + ip.address() + ":" + streamsettings.port + "/" + streamsettings.mp3Path 25 | } 26 | } 27 | 28 | module.exports = audiostream; 29 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | var chromecasts = require('chromecasts')() 2 | var audiostream = require('./audiostream.js') 3 | 4 | audiostream.start() 5 | 6 | chromecasts.on('update', function (player) { 7 | player.play(audiostream.returnIp(), {title: 'Linux Audio Cast', type: 'audio/mpeg3', images: 'https://lh6.ggpht.com/o5BSjt4xYPQXWMyfZgfhE3eA179gZLw56cBSQfupjtuM2WaZTp6z9Qqr2ar_Sz6eSmKL=w300' }) 8 | }) 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chromecast-unix-audio", 3 | "version": "0.3.3", 4 | "description": "Stream audio input to a local Chromecast device from any unix based os.", 5 | "preferGlobal": true, 6 | "main": "./lib/index.js", 7 | "bin": { 8 | "chromecast-unix-audio": "bin/index.js" 9 | }, 10 | "author": "KeizerDev", 11 | "license": "BSD", 12 | "keywords": [ 13 | "audio", 14 | "sound", 15 | "streaming", 16 | "osx", 17 | "linux", 18 | "chromecast" 19 | ], 20 | "dependencies": { 21 | "chromecasts": "~1.7.1", 22 | "ip": "~1.1.0", 23 | "shelljs": "~0.5.3" 24 | } 25 | } 26 | --------------------------------------------------------------------------------