node-upnp-remote
v1.2.0
Published
UPnP Remote Control
Downloads
71
Maintainers
Readme
UPnP Remote
Remote control for UPnP media devices (tv, speakers, amplifiers, network streamers).
Install
npm i node-upnp-remote
Usage
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);
Events
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
API
async setURI(options)
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
async on(eventName, listener)
adds UPnP event listener
async off(eventName, listener)
removes UPnP event listener
async removeAllListeners()
removes all listeners from all UPnP events
async play(speed = 1)
sets the play speed, default is 1
async pause()
pauses current playback
async stop()
stops current playback
async seek(seconds)
sets the playback time to seconds
async next()
switches to next track
async previous()
switches to previous track
async getVolume(channel = 'Master')
Gets the volume for the channel
async setVolume(volume, channel = 'Master')
Sets the volume for the channel
async getMute(channel = 'Master')
gets the mute state for the channel
async setMute(state, channel = 'Master')
sets the mute state for the channel
async getProtocolsInfo()
returns the supported protocols
async getMediaInfo()
returns the current media info
async getPositionInfo()
returns the current position
async getTransportInfo()
returns the transport info
async getTransportSettings()
returns the transport settings
async getDeviceCapabilities()
returns the device capabilities
License MIT