{"id":18805576,"url":"https://github.com/melchor629/node-chromecaster-lib","last_synced_at":"2025-10-20T03:24:52.997Z","repository":{"id":57198500,"uuid":"58191351","full_name":"melchor629/node-chromecaster-lib","owner":"melchor629","description":"Library for casting audio from your computer to Chromecast","archived":false,"fork":false,"pushed_at":"2018-10-26T14:32:55.000Z","size":151,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-27T09:51:46.974Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/melchor629.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-06T08:05:12.000Z","updated_at":"2018-12-31T14:05:12.000Z","dependencies_parsed_at":"2022-09-16T14:10:26.001Z","dependency_job_id":null,"html_url":"https://github.com/melchor629/node-chromecaster-lib","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melchor629%2Fnode-chromecaster-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melchor629%2Fnode-chromecaster-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melchor629%2Fnode-chromecaster-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/melchor629%2Fnode-chromecaster-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/melchor629","download_url":"https://codeload.github.com/melchor629/node-chromecaster-lib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248766740,"owners_count":21158301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T22:44:25.059Z","updated_at":"2025-10-20T03:24:47.939Z","avatar_url":"https://github.com/melchor629.png","language":"C","readme":"node-chromecaster-lib\n===================\nA library to send your input sound to the Chromecast.\n\nOffers a simple way to get audio from system, discovering Chromecasts and sending audio to it. Audio codec is in your hands.\n\nThis version is in (_kind of_) beta, so any help is welcome.\n\nInstallation\n----------------\nThis library currently works on OS X and Linux and Windows.\n```\n$ npm install chromecaster-lib\n```\n\nIt is not needed to have installed portaudio to compile the library. But you must provide the library either by installing it using the aproppiate package manager (on Linux and macOS) or providing the library manually (on Windows and macOS).\n\nFor electron 2.0.10 and 3.0.2, node 8 and 10, it will download a compiled version from Github. Uses the library portaudio. To execute, the library can be put on an accessible path or can be put anywhere and load it using `AudioInput.loadNativeLibrary(path: string)`.\n\n**Mac Users**: You should install portaudio using `brew install portaudio` if you have troubles.\n\n**Linux Users**: You should install `portaudio19-dev` (or equivalent) package before installing this one.\n\n**Windows Users**:\n - If you have problems compiling this library (or one of its dependencies), [see this issue](https://github.com/nodejs/node-gyp/issues/972).\n - You can compile [portaudio](http://portaudio.com) for 64bit or search a `.dll` on the internet. **(optionally)** Follow the instructions in `build/msvc/readme.txt` for compiling. Use release version. To test/use the library, copy the `portaudio_x64.dll` into the root of the project.\n - Before compiling `portaudio`, if you want to enable loopback devices on `wasapi` audio library, you should apply the Audacity patch (updated and available in this repository).\n\n**Compiling note**: If you have any troubles for compiling, you can see these [requirements](https://github.com/nodejs/node-gyp#installation) for compiling in node. Really recommended for __Windows__ users.\n\nExample\n------------\nA quick, example (_using lame encoder_):\n\n```javascript\nconst { AudioInput, ChromecastDiscover, Webcast } = require('chromecaster-lib');\nconst lame = require('lame');\n\nconst cd = new ChromecastDiscover();\ncd.on('device', function(ca) {\n    cd.stop();\n    const client = cd.createClient(ca);\n    const encoder = new lame.Encoder({\n        channels: 2,\n        bitDepth: 16,\n        sampleRate: 44100,\n        bitRate: 320,\n        outSampleRate: 44100,\n        mode: lame.JOINTSTEREO\n    });\n    const audioInput = new AudioInput();\n    const webcast = new Webcast({ port: 8080 });\n\n    //Sometimes, pipe does not work well with the first one\n    audioInput.on('data', encoder.write.bind(encoder));\n    encoder.on('data', webcast.write.bind(webcast));\n\n    client.setWebcast(webcast);\n    client.connect((err, status) =\u003e {\n        if(err) {\n            console.log(\"Could not connect to CA: %s\", err);\n        } else {\n            console.log(\"Connected to CA\");\n        }\n    });\n});\ncd.start();\n```\n\nAPI\n-----\n## AudioInput\ninherits from EventEmitter\n\n**constructor([options])**\nCreates the object passing some options. `options` object can contain the following fields, and its default values\n\n- `samplerate` *Sample rate of the input audio stream. Valid values are: 44100, 48000, 88200, 96000* [44100]\n- `bps` *Bitdepth for sample. Could be 8, 16, 24, 32* [16]\n- `channels` *Number of channels of the stream, 1 (mono) or 2 (stereo)* [2]\n- `deviceName` *name of the device which capture the audio* [system default]\n- `timePerFrame` *number of milliseconds to capture per frame* [100ms]\n\n \u003e **NOTE:** Invalid values in the above options will use the default value.\n\n \u003e **NOTE:** For `deviceName`, try with any value from `AudioInput.getDevices()`.\n\n \u003e **Observation:** If the native library is not loaded, the constructor will throw an Error.\n\n**Number open()**\nOpens the Input Audio Stream. If the return value is different from 0, then an error has occurred. In this case, see `AudioInput.Error`.\n\n**close()**\nCloses the Input Stream, in case it was opened.\n\n**pause()**\n(Un)Pauses the Input Stream.\n\n**isOpen(): boolean**\nReturns `true` if the stream is open, `false` otherwise.\n\n**isPaused(): boolean**\nReturns `true` if the stream is open and paused, or is closed.\n\n**event 'data'**\nEvery processed frame, will be emitted on this event. Event has only one argument: the interleaved audio buffer.\n\n### AudioInput.error(code: number): string\nConverts the error returned in `Number AudioInput.open()` into a string.\n\n### AudioInput.getDevices(): string[]\nReturns the devices available in the system. Useful to change the input device\nwhen creating an `AudioInput`.\n\n### AudioInput.loadNativeLibrary(path: string): boolean\nTries to load the native library `portaudio` from the path given. If the library is already loaded or cannot be found, it will throw an Error.\n\n### AudioInput.isNativeLibraryLoaded(): boolean\nReturns `true` if the native library is loaded.\n\n## Webcast\ninherits from stream.Writable\n\n**constructor([options])**\nCreates a web server to send the input audio to the Chromecast (_or something else_), and opens the server. The options object and its default values:\n\n- `port` *port to listen on* [3000]\n- `contentType` *MIME type of the input stream* [audio/mp3]\n\n**stop()**\nCloses the server\n\n**write(buffer: Buffer | string, encoding?: string, cbk?: () =\u003e void)**\nWrites some bytes to the clients that are listening. Encoding is usually omitted.\n\n**localIp: string**\nObtains the ip of the machine in the local network\n\n**contentType: string**\nObtains the contentType of the input stream, that is, the stream that will output to the server.\n\n**port: number**\nGets the port the server is listening on.\n\n**event 'connect'**\nWhen some client is connected to the local web server. The event passes (as object) these attributes:\n\n - id: _some kind of id for the client connected_ the position on the internal clients array\n - address: _the address of the device's endpoint_\n - port: _the port of the device's endpoint_\n - family: _IPv6 or IPv4_ (it's a string, see node's socket documentation)\n - headers: _object with the headers of the request_\n\n**event 'disconnect'**\nWhen a client closes the connexion, this event is emitted passing the same object as in `connect` event.\n\n## ChromecastDiscover\ninherits from events.EventEmitter\n\n**constructor()**\nPrepares the discovering of Chromecasts. No options required.\n\n**start()**\nStarts searching for Chromecasts.\n\n**stop()**\nStops searching Chromecasts.\n\n**getDeviceAddress(name: string): string | null**\nGets the IP address of the device named.\n\n**getDeviceNameForNumber(pos: number): string**\nGets the device number for the nth device that was found. `number` goes from 0 to devicesFound - 1.\n\n**forEachClient(cbk: (devName: string) =\u003e void)**\nDoes a forEach on every device found passing its name to the callback.\n\n**createClient(nameOrDevice: string | ChromecastDeviceInfo): ChromecastClient**\nCreates a ChromecastDevice object for the named device.\n\n**event 'device'**\nEvent emitted when a device has been found. Argument is the name of the device.\n\n## ChromecastDevice\ninherits from events.EventEmitter\n\n**constructor(device)**\nIs not recommended create ChromecastDevices directly, use instead `ChromecastDiscover.createClient()`.\n\n**setWebcast(webcast)**\nSets the `Webcast` object that your are using. Is a **mandatory** call this method before  calling `connect` .\n\n**connect(cbk)**\n**connect(streamName, cbk)**\nConnects to the Chromecast device and sets its stream name to `streamName` of default name (`Chromecaster lib stream`). Callback have a signature of `function(err, status)`.\n\nAny error in the connexion, is reported calling the callback with `err` set to the error.\n\nIf the connexion succeeds, `cbk` will be called with `err` set to `null` and with the status of the device. The device will play automatically.\n\n**getVolume(cbk)**\nGets the volume of the device asynchronously. The signature of `cbk` is `function(err, volume)` where `volume` is a number between 0 and 1. If the client is not connected, `err` and `volume` are null.\n\n**setVolume(volume [, cbk])**\nSets the volume of the device asynchronously.  Volume is a number [0,1]. Values not in the range are clamped. The signature of `cbk` is `function(err, volume)` where `volume` is a number between 0 and 1. If the client is not connected, `err` and `volume` are null.\n\n**isMuted(cbk)**\nGets if the device is muted or not asynchronously. `cbk` has signature of `function(err, muted)`.\n\n**setMute(muted [, cbk])**\nChange mute of the device asynchronously. `cbk` has signature of `function(err, muted)`.\n\n**play([cbk])**\nNotifies the Chromecast to start playing. By default, the Chromecast is always playing.\n\n**pause([cbk])**\nNotifies the Chromecast to pause the stream.\n\n**stop([cbk])**\nNotifies the Chromecast to stop the stream.\n\n**close()**\nStops the stream and closes the connexion to the device.\n\n## About the patch\n\nThere's available a patch for `portaudio` sources (v19 20161030) that enables loopback devices on Windows under the `wasapi` API. The original patch is available [here](https://github.com/audacity/audacity/blob/master/lib-src/portaudio-v19/wasapi-loopback.patch) (under GPLv2). It is a modification to make it apply under the source code of v19 20161030 version of the library.\n\nIt is an **optional** patch, but applying it, will show loopback devices in the list of audio input devices.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmelchor629%2Fnode-chromecaster-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmelchor629%2Fnode-chromecaster-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmelchor629%2Fnode-chromecaster-lib/lists"}