{"id":16834684,"url":"https://github.com/mscdex/paclient","last_synced_at":"2025-06-25T18:05:13.697Z","repository":{"id":57317898,"uuid":"101845868","full_name":"mscdex/paclient","owner":"mscdex","description":"PulseAudio client written in pure JavaScript for node.js","archived":false,"fork":false,"pushed_at":"2018-11-11T10:28:03.000Z","size":27,"stargazers_count":24,"open_issues_count":8,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-12T22:18:49.847Z","etag":null,"topics":["javascript","nodejs","pulseaudio","pulseaudio-client"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mscdex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-30T06:29:17.000Z","updated_at":"2024-12-09T08:13:28.000Z","dependencies_parsed_at":"2022-08-25T20:40:25.120Z","dependency_job_id":null,"html_url":"https://github.com/mscdex/paclient","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fpaclient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fpaclient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fpaclient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mscdex%2Fpaclient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mscdex","download_url":"https://codeload.github.com/mscdex/paclient/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244907420,"owners_count":20529850,"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":["javascript","nodejs","pulseaudio","pulseaudio-client"],"created_at":"2024-10-13T12:07:22.429Z","updated_at":"2025-03-22T04:30:46.149Z","avatar_url":"https://github.com/mscdex.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Description\n\nA PulseAudio client written in pure JavaScript for [node.js](http://nodejs.org/).\n\nCurrently most commands are implemented. SHM/MemFD-related commands are not supported.\n\n# Table of Contents\n\n* [Requirements](#requirements)\n* [Installation](#installation)\n* [Examples](#examples)\n  * [Subscribe to all server events](#subscribe-to-all-server-events)\n* [API](#api)\n  * [Client](#client)\n      * [Client events](#client-events)\n      * [Client methods](#client-methods)\n\n## Requirements\n\n* [node.js](http://nodejs.org/) -- v6.0.0 or newer\n\n## Installation\n\n    npm install paclient\n\n## Examples\n\n### Subscribe to all server events\n\n```js\nconst PAClient = require('paclient');\n\nconst pa = new PAClient();\npa.on('ready', () =\u003e {\n  console.log('Ready');\n  pa.subscribe('all');\n}).on('close', () =\u003e {\n  console.log('Connection closed');\n}).on('new', (type, index) =\u003e {\n  pa[getFnFromType(type)](index, (err, info) =\u003e {\n    if (err) {\n      console.log(`Could not fetch ${type}, index ${index}: ${err.message}`);\n      return;\n    }\n    var name = info.name || info.description || '\u003cunknown\u003e';\n    console.log(`\"${name}\" (${type}) added`);\n  });\n}).on('change', (type, index) =\u003e {\n  pa[getFnFromType(type)](index, (err, info) =\u003e {\n    if (err) {\n      console.log(`Could not fetch ${type}, index ${index}: ${err.message}`);\n      return;\n    }\n    var name = info.name || info.description || '\u003cunknown\u003e';\n    console.log(`\"${name}\" (${type}) changed`);\n  });\n}).on('remove', (type, index) =\u003e {\n  console.log(`Removed ${type}, index #${index}`);\n});\n\npa.connect();\n\nfunction getFnFromType(type) {\n  var fn;\n  switch (type) {\n    case 'sink':\n    case 'card':\n    case 'source': fn = type; break;\n    case 'sinkInput':\n    case 'sourceOutput':\n    case 'client':\n    case 'module': fn = `${type}ByIndex`; break;\n    default:\n      throw new Error('Unexpected type: ' + type);\n  }\n  return 'get' + fn[0].toUpperCase() + fn.slice(1);\n}\n```\n\n## API\n\n### Client\n\n#### Client events\n\n* **ready**() - A successful, authenticated connection has been made.\n\n* **close**() - The connection to the server has been closed.\n\n* **new**(\u003c _string_ \u003etype, \u003c _integer_ \u003eindex) - A new entity has been added.\n\n* **change**(\u003c _string_ \u003etype, \u003c _integer_ \u003eindex) - An existing entity has changed.\n\n* **remove**(\u003c _string_ \u003etype, \u003c _integer_ \u003eindex) - An existing entity has been removed.\n\n#### Client methods\n\n* **(constructor)**() - Creates and returns a new Client instance.\n\n* **connect**([\u003c _object_ \u003econfig]) - _(void)_ - Attempts a connection to a server using the information given in `config`. If no `path` or `host` are supplied then connection details are autodetected using the same algorithm as the official PulseAudio client library. Valid `config` options are:\n\n    * **path** - _string_ - Path to a UNIX socket of the server. **Default:** Autodetected\n\n    * **host** - _string_ - Hostname or IP address of the server. **Default:** Autodetected\n\n    * **port** - _integer_ - Port number of the server. **Default:** `4713`\n\n    * **cookie** - _mixed_ - An explicit cookie value to use when authenticating with the server. This can either be a _Buffer_ or a hex string of the appropriate length. **Default:** Autodetected\n\n    * **properties** - _object_ - A set of properties to associate with the client on the server. These can be seen by other clients. **Default:** `{ application: { name: 'paclient.js' } }`\n\n* **end**() - _(void)_ - If connected, this will close the connection to the server.\n\n* **getModules**(\u003c _function_ \u003ecallback) - _(void)_ - Retrieves a list of loaded modules. `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _array_ \u003emodules.\n\n* **getClients**(\u003c _function_ \u003ecallback) - _(void)_ - Retrieves a list of connected clients. `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _array_ \u003eclients.\n\n* **getSinks**(\u003c _function_ \u003ecallback) - _(void)_ - Retrieves a list of available sinks (outputs). `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _array_ \u003esinks.\n\n* **getSources**(\u003c _function_ \u003ecallback) - _(void)_ - Retrieves a list of available sources (inputs). `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _array_ \u003esources.\n\n* **getSinkInputs**(\u003c _function_ \u003ecallback) - _(void)_ - Retrieves a list of available sink inputs (streams connected to outputs). `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _array_ \u003esinkInputs.\n\n* **getSourceOutputs**(\u003c _function_ \u003ecallback) - _(void)_ - Retrieves a list of available source outputs (streams connected to inputs). `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _array_ \u003esourceOutputs.\n\n* **getCards**(\u003c _function_ \u003ecallback) - _(void)_ - Retrieves a list of available cards (hardware devices that usually combine a single source (for recording) and a single sink (for playback)). `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _array_ \u003ecards.\n\n* **getServerInfo**(\u003c _function_ \u003ecallback) - _(void)_ - Retrieves information about the server. `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _object_ \u003einfo.\n\n* **getModuleByIndex**(\u003c _integer_ \u003eindex, \u003c _function_ \u003ecallback) - _(void)_ - Retrieves a module by its index. `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _object_ \u003emodule.\n\n* **getClientByIndex**(\u003c _integer_ \u003eindex, \u003c _function_ \u003ecallback) - _(void)_ - Retrieves a client by its index. `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _object_ \u003eclient.\n\n* **getSink**(\u003c _mixed_ \u003ecriteria, \u003c _function_ \u003ecallback) - _(void)_ - Retrieves a sink by either its index (_integer_) or its name (_string_). `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _object_ \u003esink.\n\n* **getSource**(\u003c _mixed_ \u003ecriteria, \u003c _function_ \u003ecallback) - _(void)_ - Retrieves a source by either its index (_integer_) or its name (_string_). `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _object_ \u003esource.\n\n* **getSinkInputByIndex**(\u003c _integer_ \u003eindex, \u003c _function_ \u003ecallback) - _(void)_ - Retrieves a sink input by its index. `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _object_ \u003esinkInput.\n\n* **getSourceOutputByIndex**(\u003c _integer_ \u003eindex, \u003c _function_ \u003ecallback) - _(void)_ - Retrieves a source output by its index. `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _object_ \u003esourceOutput.\n\n* **getCard**(\u003c _mixed_ \u003ecriteria, \u003c _function_ \u003ecallback) - _(void)_ - Retrieves a card by either its index (_integer_) or its name (_string_). `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _object_ \u003ecard.\n\n* **getSinkIndexByName**(\u003c _string_ \u003ename, \u003c _function_ \u003ecallback) - _(void)_ - Retrieves the index for a sink given its `name`. `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _integer_ \u003eindex.\n\n* **getSourceIndexByName**(\u003c _string_ \u003ename, \u003c _function_ \u003ecallback) - _(void)_ - Retrieves the index for a source given its `name`. `callback` has 2 parameters: \u003c _Error_ \u003eerr, \u003c _integer_ \u003eindex.\n\n* **setSinkVolumes**(\u003c _mixed_ \u003ecriteria, \u003c _array_ \u003evolumes, \u003c _function_ \u003ecallback) - _(void)_ - Sets the volumes for each of a sink's channels. `criteria` can be an index (_integer_) or a name (_string_). `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **setSourceVolumes**(\u003c _mixed_ \u003ecriteria, \u003c _array_ \u003evolumes, \u003c _function_ \u003ecallback) - _(void)_ - Sets the volumes for each of a source's channels. `criteria` can be an index (_integer_) or a name (_string_). `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **setSinkInputVolumesByIndex**(\u003c _integer_ \u003eindex, \u003c _array_ \u003evolumes, \u003c _function_ \u003ecallback) - _(void)_ - Sets the volumes for each of a sink input's channels. `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **setSourceOutputVolumesByIndex**(\u003c _integer_ \u003eindex, \u003c _array_ \u003evolumes, \u003c _function_ \u003ecallback) - _(void)_ - Sets the volumes for each of a source output's channels. `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **setSinkMute**(\u003c _mixed_ \u003ecriteria, \u003c _boolean_ \u003emuted, \u003c _function_ \u003ecallback) - _(void)_ - Sets the muted status for a sink by either its index (_integer_) or its name (_string_). `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **setSourceMute**(\u003c _mixed_ \u003ecriteria, \u003c _boolean_ \u003emuted, \u003c _function_ \u003ecallback) - _(void)_ - Sets the muted status for a source by either its index (_integer_) or its name (_string_). `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **setSinkInputMuteByIndex**(\u003c _integer_ \u003eindex, \u003c _boolean_ \u003emuted, \u003c _function_ \u003ecallback) - _(void)_ - Sets the muted status for a sink input. `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **setSourceOutputMuteByIndex**(\u003c _integer_ \u003eindex, \u003c _boolean_ \u003emuted, \u003c _function_ \u003ecallback) - _(void)_ - Sets the muted status for a source output. `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **setSinkSuspend**(\u003c _mixed_ \u003ecriteria, \u003c _boolean_ \u003esuspended, \u003c _function_ \u003ecallback) - _(void)_ - Sets the suspended status for a sink by either its index (_integer_) or its name (_string_). `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **setSourceSuspend**(\u003c _mixed_ \u003ecriteria, \u003c _boolean_ \u003esuspended, \u003c _function_ \u003ecallback) - _(void)_ - Sets the suspended status for a source by either its index (_integer_) or its name (_string_). `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **setDefaultSinkByName**(\u003c _string_ \u003ename, \u003c _function_ \u003ecallback) - _(void)_ - Sets the default sink. `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **setDefaultSourceByName**(\u003c _string_ \u003ename, \u003c _function_ \u003ecallback) - _(void)_ - Sets the default source. `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **killClientByIndex**(\u003c _integer_ \u003eindex, \u003c _function_ \u003ecallback) - _(void)_ - Terminates the connection of the specified client. `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **killSinkInputByIndex**(\u003c _integer_ \u003eindex, \u003c _function_ \u003ecallback) - _(void)_ - Terminates a sink input. `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **killSourceOutputByIndex**(\u003c _integer_ \u003eindex, \u003c _function_ \u003ecallback) - _(void)_ - Terminates a source output. `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **moveSinkInput**(\u003c _integer_ \u003eindex, \u003c _mixed_ \u003edestSink, \u003c _function_ \u003ecallback) - _(void)_ - Moves a sink input to a different sink identified by either its index (_integer_) or its name (_string_). `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **moveSourceOutput**(\u003c _integer_ \u003eindex, \u003c _mixed_ \u003edestSink, \u003c _function_ \u003ecallback) - _(void)_ - Moves a source output to a different source identified by either its index (_integer_) or its name (_string_). `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **setSinkPort**(\u003c _mixed_ \u003ecriteria, \u003c _string_ \u003eportName, \u003c _function_ \u003ecallback) - _(void)_ - Sets the port for a sink identified by either its index (_integer_) or its name (_string_). `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **setSourcePort**(\u003c _mixed_ \u003ecriteria, \u003c _string_ \u003eportName, \u003c _function_ \u003ecallback) - _(void)_ - Sets the port for a source identified by either its index (_integer_) or its name (_string_). `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **setCardProfile**(\u003c _mixed_ \u003ecriteria, \u003c _string_ \u003eprofileName, \u003c _function_ \u003ecallback) - _(void)_ - Sets the profile for a card identified by either its index (_integer_) or its name (_string_). `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **updateClientProperties**(\u003c _object_ \u003eproperties, \u003c _string_ \u003emode, \u003c _function_ \u003ecallback) - _(void)_ - Updates this client's server-side properties. The update behavior is governed by `mode` which can be one of: `'set'` (any/all old properties are removed), `'update'` (only add properties that do not already exist), or `'replace'` (only overwrite property values for existing properties). `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **removeClientProperties**(\u003c _array_ \u003epropertyNames, \u003c _function_ \u003ecallback) - _(void)_ - Removes specified properties from this client's server-side properties. `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n\n* **subscribe**(\u003c _mixed_ \u003eevents, \u003c _function_ \u003ecallback) - _(void)_ - Sets the event subscription for events emitted by the server. `events` can either be a _string_ or _array_ of strings containing one or more of: `'none'`, `'all'`, `'sink'`, `'source'`, `'sinkInput'`, `'sourceOutput'`, `'module'`, `'client'`, `'sampleCache'`, `'global'`, or `'card'`. `callback` has 1 parameter: \u003c _Error_ \u003eerr.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscdex%2Fpaclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmscdex%2Fpaclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmscdex%2Fpaclient/lists"}