Skip to content

Commit

Permalink
Update readme with more usage information
Browse files Browse the repository at this point in the history
  • Loading branch information
Corentin Mors committed Sep 5, 2023
1 parent 2503cb8 commit 7348ba7
Showing 1 changed file with 45 additions and 2 deletions.
47 changes: 45 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,40 @@ import upnp from 'upnp-client';

const client = new upnp.UpnpMediaRendererClient('http://192.168.1.50:54380/MediaRenderer_HT-A9.xml');

// TODO: To be written
const options = {
autoplay: true,
contentType: 'audio/flac',
dlnaFeatures: dlnaContentFeatures, // see below for dlnaHelpers
metadata: {
title: 'My song',
creator: 'My creator',
artist: 'My artist',
album: 'My album',
albumArtURI: 'http://127.0.0.1/albumArtURI.jpg',
type: 'audio'
}
};

await client.play();
await client.load('http://127.0.0.1/music.flac', options);

await client.loadNext('http://127.0.0.1/next-music.flac', options);

await client.pause();

await client.play();

await client.stop();

await client.next();

await client.previous();

await client.seek(60);

// you can also call any AVTransport action supported by your device
const response = await client.callAVTransport('YourCustomAVTransportCall', {
InstanceID: client.instanceId
});
```

## Usage of dlnaHelpers
Expand All @@ -77,6 +102,24 @@ const dlnaContentFeatures =
`${upnp.dlnaHelpers.defaultFlags.DLNA_STREAMING_TIME_BASED_FLAGS}`;
```

## Tips and tricks

In the metadata you're passing to your speaker, make sure to avoid using accents and special characters.

Here is a simple helper you could use:

```ts
const escapeSpecialChars = (value: string) => {
return value
.normalize('NFD')
.replace(/[\u0300-\u036f]/g, '') // remove all accents from characters
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(//g, "'");
};
```

## Debugging

Run with debug traces
Expand Down

0 comments on commit 7348ba7

Please sign in to comment.