# upnp-mediarenderer-client

> An UPnP/DLNA MediaRenderer client

Latest version **1.4.0** (published 2020-05-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install upnp-mediarenderer-client
pnpm add upnp-mediarenderer-client
yarn add upnp-mediarenderer-client
bun add upnp-mediarenderer-client
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2020-05-27 |
| First published | 2014-10-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/upnp-mediarenderer-client) |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 12.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 135 |
| Author | thibauts |
| Maintainers | thibauts |
| Keywords | upnp, dlna, mediarenderer, tv |

## Links

- npm: https://www.npmjs.com/package/upnp-mediarenderer-client
- Repository: https://github.com/thibauts/node-upnp-mediarenderer-client
- Homepage: https://github.com/thibauts/node-upnp-mediarenderer-client#readme
- Issues: https://github.com/thibauts/node-upnp-mediarenderer-client/issues
- npm.io page: https://npm.io/package/upnp-mediarenderer-client

## Dependencies (3)

- [debug](https://npm.io/package/debug.md) ^2.1.3
- [elementtree](https://npm.io/package/elementtree.md) ^0.1.6
- [upnp-device-client](https://npm.io/package/upnp-device-client.md) ^1.0.0

## Recent versions

- 1.4.0 (latest) — 2020-05-27
- 1.3.0 — 2020-05-27
- 1.2.4 — 2016-06-17
- 1.2.3 — 2016-06-02
- 1.2.2 — 2016-03-07
- 1.2.1 — 2015-04-19
- 1.2.0 — 2015-04-19
- 1.1.0 — 2015-04-19
- 1.0.0 — 2015-04-18
- 0.0.3 — 2015-02-26
- 0.0.2 — 2015-01-02
- 0.0.1 — 2014-10-21

## README

upnp-mediarenderer-client
=========================
### An UPnP/DLNA MediaRenderer client

This module allows you to control an UPnP/DLNA MediaRenderer directly (usually your TV set). It implements load, play, pause, stop and seek commands.

Events coming from the MediaRenderer (ie. fired from the TV remote) such as `playing`, `paused`, `stopped` can be listened to.

External subtitles are supported through DIDL-Lite metadata, but be aware that some MediaRenderers require the HTTP server serving the media file to return specific headers as illustrated in this [gist](https://gist.github.com/thibauts/5f5f8d8ce6566c8289e6). Also, some MediaRenderers don't support external subtitles at all.

Installation
------------

```bash
$ npm install upnp-mediarenderer-client
```

Usage
-----

```javascript
var MediaRendererClient = require('upnp-mediarenderer-client');

// Instanciate a client with a device description URL (discovered by SSDP)
var client = new MediaRendererClient('http://192.168.1.50:4873/foo.xml');

// Load a stream with subtitles and play it immediately
var options = { 
  autoplay: true,
  contentType: 'video/avi',
  metadata: {
    title: 'Some Movie Title',
    creator: 'John Doe',
    type: 'video', // can be 'video', 'audio' or 'image'
    subtitlesUrl: 'http://url.to.some/subtitles.srt'
  }
};

client.load('http://url.to.some/stream.avi', options, function(err, result) {
  if(err) throw err;
  console.log('playing ...');
});

// Pause the current playing stream
client.pause();

// Unpause
client.play();

// Stop
client.stop();

// Seek to 10 minutes
client.seek(10 * 60);

// Get the volume
client.getVolume(function(err, volume) {
  if(err) throw err;
  console.log(volume); // the volume range is 0-100
});

// Set the volume
client.setVolume(40, function(err) {
  if(err) throw err;
  console.log("volume is now", volume);
});

client.on('status', function(status) {
  // Reports the full state of the AVTransport service the first time it fires,
  // then reports diffs. Can be used to maintain a reliable copy of the
  // service internal state.
  console.log(status);
});

client.on('loading', function() {
  console.log('loading');
});

client.on('playing', function() {
  console.log('playing');

  client.getPosition(function(err, position) {
    console.log(position); // Current position in seconds
  });

  client.getDuration(function(err, duration) {
    console.log(duration); // Media duration in seconds
  });
});

client.on('paused', function() {
  console.log('paused');
});

client.on('stopped', function() {
  console.log('stopped');
});

client.on('speedChanged', function(speed) {
  // Fired when the user rewinds of fast-forwards the media from the remote
  console.log('speedChanged', speed);
});
```

---
_Source: https://npm.io/package/upnp-mediarenderer-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
