Skip to content

Commit cb97844

Browse files
sseiberjishi
authored andcommitted
tunein radio action (#470)
* Ignore VSCode launch files, macos folder cache files * tunein radio action * Update readme for tunein action
1 parent f7a5f5f commit cb97844

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@ obj/
1313
*.crt
1414
*.pfx
1515
*.key
16+
17+
# VS
18+
.vscode
19+
.vscode/launch.json
20+
21+
# Ignore Mac DS_Store files
22+
.DS_Store

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,17 @@ Your Pandora credentials need to be added to the settings.json file
755755
```
756756

757757

758+
Tunein
759+
----------------------
760+
Given a station id this will play the streaming broadcast via the tunein service. You can find tunein station ids via services like [radiotime](http://opml.radiotime.com/)
761+
762+
The following endpoint is available:
763+
764+
```
765+
/RoomName/tunein/play/{station id}
766+
```
767+
768+
758769
Music Search and Play
759770
----------------------
760771
Perform a search for a song, artist, album or station and begin playing. Supports Apple Music, Spotify, Deezer, Deezer Elite, and your local Music Library.

lib/actions/tunein.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'use strict';
2+
3+
function getTuneInMetadata(uri, serviceType) {
4+
return `<DIDL-Lite xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:upnp="urn:schemas-upnp-org:metadata-1-0/upnp/"
5+
xmlns:r="urn:schemas-rinconnetworks-com:metadata-1-0/" xmlns="urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/">
6+
<item id="F00092020s${uri}" parentID="L" restricted="true"><dc:title>tunein</dc:title><upnp:class>object.item.audioItem.audioBroadcast</upnp:class>
7+
<desc id="cdudn" nameSpace="urn:schemas-rinconnetworks-com:metadata-1-0/">SA_RINCON${serviceType}_</desc></item></DIDL-Lite>`;
8+
}
9+
10+
function tuneIn(player, values) {
11+
const action = values[0];
12+
const tuneInUri = values[1];
13+
const encodedTuneInUri = encodeURIComponent(tuneInUri);
14+
const sid = player.system.getServiceId('TuneIn');
15+
const metadata = getTuneInMetadata(encodedTuneInUri, player.system.getServiceType('TuneIn'));
16+
const uri = `x-sonosapi-stream:s${encodedTuneInUri}?sid=${sid}&flags=8224&sn=0`;
17+
18+
if (!tuneInUri) {
19+
return Promise.reject('Expected TuneIn station id');
20+
}
21+
22+
if (action == 'play') {
23+
return player.coordinator.setAVTransport(uri, metadata)
24+
.then(() => player.coordinator.play());
25+
}
26+
27+
return Promise.reject('TuneIn only handles the {play} action');
28+
}
29+
30+
module.exports = function (api) {
31+
api.registerAction('tunein', tuneIn);
32+
}

0 commit comments

Comments
 (0)