Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thibauts/node-upnp-device-client
A simple and versatile UPnP device client
https://github.com/thibauts/node-upnp-device-client
Last synced: 24 days ago
JSON representation
A simple and versatile UPnP device client
- Host: GitHub
- URL: https://github.com/thibauts/node-upnp-device-client
- Owner: thibauts
- License: mit
- Created: 2014-10-20T23:57:17.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-05-21T23:34:29.000Z (8 months ago)
- Last Synced: 2024-11-30T13:50:42.724Z (about 1 month ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 34
- Watchers: 6
- Forks: 23
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
upnp-device-client
==================
### A simple and versatile UPnP device clientThis module can query UPnP devices descriptions, service descriptions and call actions on services. It also provides a simple interface to subscribe to UPnP services events.
Install
-------```bash
$ npm install upnp-device-client
```Usage
-----```javascript
var Client = require('upnp-device-client');// Instanciate a client with a device description URL (discovered by SSDP)
var client = new Client('http://192.168.1.50:4873/foo.xml');// Get the device description
client.getDeviceDescription(function(err, description) {
if(err) throw err;
console.log(description);
});// Get the device's AVTransport service description
client.getServiceDescription('AVTransport', function(err, description) {
if(err) throw err;
console.log(description);
});// Call GetMediaInfo on the AVTransport service
client.callAction('AVTransport', 'GetMediaInfo', { InstanceID: 0 }, function(err, result) {
if(err) throw err;
console.log(result); // => { NrTracks: '1', MediaDuration: ... }
});client.subscribe('AVTransport', function(e) {
// Will receive events like { InstanceID: 0, TransportState: 'PLAYING' } when playing media
console.log(e);
});// client.unsubscribe('AVTransport', listener);
```Run with debug traces
```bash
$ DEBUG=* node index.js
```