Dynamic Content with Placeholder API
The article explains how you can use placeholders instead of static text in modules.
You can use placeholders in modules using the {{variable|default}} format to populate dynamic content through the Player API. The value “variable” corresponds to the key of the API call, which is replaced by the value given there. In addition, you can optionally use “default” to define a default value for the placeholder that is used if no value or an empty text (“”) is returned in the Player API for the key that is used.
This is my example text with a dynamic number “{{number|50}}” inside the text.
Calling the Player API at the endpoint with the parameters { “key”: “number”, “value”: “100” } will change the result from “{{number|50}}” to “100”.
This is my example text with a dynamic number “100” inside the text.
In the initial state of the player after startup or by clearing the value via API, the default value “50” is displayed in this example.
This is my example text with a dynamic number “50” inside the text.
Of course, you can use multiple placeholders in the module at the same time.
You can also set a variable via the Server API. To do so, send a POST request to the endpoint https://api.framr.tv/tv/device/actions/var/ and include the following parameters:
- secret: API key … you can generate an API key in the group settings
- id: Player ID … you can find the Player ID at the end of the browser URL after clicking on a player in the cockpit
- key: Variable name
- value: Value
To set multiple variables simultaneously via the Server API, use the following parameters:
- secret: API key … you can generate an API key in the group settings
- id: Player ID … you can find the Player ID at the end of the browser URL after clicking on a player in the cockpit
- key[]: Array of variable names
- value[]: Array of corresponding values
- …
- key[]: Array of variable names
- value[]: Array of corresponding values
This method allows you to set multiple key-value pairs in a single request, which is particularly useful for efficiently adjusting multiple dynamic contents in the player.
This is my sample text with a dynamic number “{{zahl|50}}” in the text.
By calling the Player API to the endpoint with the parameters { “key”: “zahl”, “value”: “100” }, the output will change from “{{zahl|50}}” to “100”.
This is my sample text with a dynamic number “100” in the text.
In the initial state of the player after startup, or by deleting the value via the API, the standard value “50” will be displayed again for this example.