Remote control for UPnP media devices (tv, speakers, amplifiers, network streamers).
npm i node-upnp-remote
const UPnPRemote = require('node-upnp-remote');
const remote = new UPnPRemote({
url: 'http://192.168.1.150:44042/some.xml'
});
function volumeHandler(vol) {
console.log('Volume', vol);
}
await remote.on('Volume', volumeHandler);
const volume = await remote.getVolume();
await remote.setVolume(volume + 1);
await remote.off('Volume', volumeHandler);
UPnP Remote adds following events for convenience:
Transitioning
Playing
Paused
Stopped
note that all events names start with a capital letter as it is defined in UPnP
loads the media file to the device. Options are:
- protocolInfo – protocol information
- upnpClass - string, or you can use
const upnpclass = require('node-upnp-remote/upnpclass');
- autoplay - boolean
- uri – string, uri to the file
- title – string, file title
- creator - string, file creator
or
- protocolInfo – protocol information
- uri – string, uri to the file
- metadata – object that reperesent metadata XML. Example:
{
"@id": 0,
"@parentId": -1,
"@restricted": false,
"upnp:class": "object.item.audioItem",
"dc:title": "Title",
"dc:creator": "Artist",
"res": {
"@protocolInfo": "http-get:*:video/mp3:*",
"#text": "https://archive.org/download/testmp3testfile/mpthreetest.mp3"
}
}
Properties names start with '@' will be parsed as attributes in the XML
adds UPnP event listener
removes UPnP event listener
removes all listeners from all UPnP events
sets the play speed, default is 1
pauses current playback
stops current playback
sets the playback time to seconds
switches to next track
switches to previous track
Gets the volume for the channel
Sets the volume for the channel
gets the mute state for the channel
sets the mute state for the channel
returns the supported protocols
returns the current media info
returns the current position
returns the transport info
returns the transport settings
returns the device capabilities
License MIT