Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

episodeSelector functionality added #10

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

theovassiliou
Copy link

added a new functionality called episode selector.

Motivation

It is not so uncommon that you would like to randomly select a content from your soundtouch location. In our household, the kids have a demand to have on a specific preset a regularly changing audio book available, but without having to take a computer, phone or tablet into their hands. Other application areas could be to rotate through a list of internet radio stations.

Requirement 1

In order to store a content on a given preset we must be able to reference the content. Soundtouch uses a combination of source, sourceAccount and location information to reference this information. We are using a music libary on a NAS. From this content there is a relatively small amount of content that we want to select from. In our case some 200 episodes. Therefore you should be able to create this pool of content with the information required by the SoundTouch system. For this I created the episodeCollector.js script.

Usage

 node episodeCollector.js

Will start a service that listens to update from a specific device as named in collectorSettings.json.
Select the named device in your SoundTouch-app and select a new content. This content will be added todata-store/libraryContent.json. The file will be created if not existent. Select all content in the SoundTouch-App one by one that you would like to add to the libaryContent. If selecting the same content multple times, only one reference will be created in libraryContent.

Requirement 2

We need a functionality where we can trigger an action that

  • randomly selects one content from libraryContent and
  • stores it at a given preset, if given or the default one, if none is provided

Because of the limitations of the SoundTouch-API it is not possible to store a content directly for a preset. Therefore we introduced the following REST-call

/:deviceName/auto/episodeSelector/:presetKey?

In order to program a preset we

  • select a device
  • start playing the desired content
  • pushing and holding the preset key for around a second
  • releasing the key
  • stopping the playback of the content

Just to make it a little bit safe, we reduce the volume on the device and restore the original volume afterwards.

The function returns a JSON object of the following format:

{
    "album": "035 Und Der Hoehlenmensch",
    "entry": "0$1$18$3340$19925$20556",
    "source": "STORED_MUSIC",
    "sourceAccount": "55076f6e-6b79-1d65-a4eb-00089bea8bd7/0",
    "presetKey": 6
}

or
416 - Range not satisfied error code with

{
    "message": "presetKey should be between 1 and 6"
}

Requirement 3

After a while we did not know exactly what content is stored in the libraryContent. Therefore we introduced a REST-call

 /auto/getAllEpisodes

which returns a list of all episodes as a json object of the format:

{
    "0$1$18$3340$19925$21162": {
        "source": "STORED_MUSIC",
        "sourceAccount": "55076f6e-6b79-1d65-a4eb-00089bea8bd7/0",
        "name": "001 - Und der Super Papagei"
    },

Final remarks

As a result we have been able to create a small framework to have some content available for selection as preset. By exposing this functionality via a REST-API we are able to regularly change the content of presets for example via a cron-job or similar.

As I believe this could be usefull for other too, I propose this pull request. It should be automatically mergeable

Tested with

I tested this with Soundtouch system consisting of 6 Boses, stored media and internet radio presets.

NOTE

In order to programm a preset we have a push and HOLD the key for a while. A small extension was required in api.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant