episodeSelector functionality added #10
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.jsscript.Usage
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 to
data-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 inlibraryContent.Requirement 2
We need a functionality where we can trigger an action that
libraryContentandBecause 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
In order to program a preset we
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 satisfiederror code withRequirement 3
After a while we did not know exactly what content is stored in the libraryContent. Therefore we introduced a REST-call
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