There is now a release candidate for the remote control feature. It’s in the next
branch of the package. You can import it here.
All plugins can now receive RPC calls. The “MainPlayer”, responsible for controlling the top-level playback now exposes the following functions:
play_next
: Switches to the next scheduled item after a very short ~0.5s delay
add_filter
: Adds a filter to the playback that restricts which of the items in the playlist should be played. You can filter on tags set on either the assets or extra tags set on the slot. Filter can be either active for a set number of content cycles (in which case the next added filter becomes active) or run indefinitely until replaced or removed.
set_filter
: Same, but removes all existing filters first.
reset_filter
: Removes all filters. The playlist plays as configured in the setup.
How to use:
Using the API:
curl -u:$API_KEY \
https://info-beamer.com/api/v1/device/$DEVICE_ID/service/root/plugin-rpc \
'data=["MainPlayer", "play_next"]'
This will call the method play_next
on the MainPlayer
object. It will cause it to interrupt the currently playing item and play the next as soon as possible. As there is a bit of synchronization required due to the package potentially communicating with other device within the same playback group, this might take a short moment, but not more than 1 second.
curl -u:$API_KEY \
https://info-beamer.com/api/v1/device/$DEVICE_ID/service/root/plugin-rpc \
'data=["MainPlayer", "set_filter", [["test"]], 3]'
The set_filter
call takes two arguments, the last one is optional. The first is a list of list of strings. Strings are tag value and the list form a condition that decides if a playlist item becomes active. The inner list is logically and
ed, while the out list of list or
s the inner lists. So [["ad"], ["promotion", "friday"]]
selects all items that have either the “ad” tag or both the “promotion” and “friday” tags. In the above example, this selects any item that has at least the “test” tag.
The second argument (3
) in the example sets the number of playback cycles this filter remains active. Once a playlist starts from the beginning, the counter is decreased and once it reaches zero, the filter is removed.
These calls can also be triggered from the network, assuming the “Remote Control” setting in the setup is switched to “Allow network control”. Via port 3000 UDP you can send messages in the following format, which is basically what the API calls above directly translates to:
plugin-rpc:["MainPlayer","play_next"]
Right now there isn’t any message source filtering, so anyone reaching UDP port 3000 on a Pi could trigger that.
I think that should do it. Feedback welcome.