Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
|
Programatic time-based resources for Skins
Skin timers are skin resources that are dependent on time and can be fully controlled from skins either using Builtin functions or Infolabels and Boolean conditions. One can see them as stopwatches that can be activated and deactivated automatically depending on the value of info expressions or simply activated/deactivated manually from builtins. The framework was created to allow skins to control the visibility of windows (and controls) depending on the elapsed time of timers the skin defines. Skin timers allow multiple use cases in skins, previously only available via the execution of python scripts:
Skin timers are defined in the Timers.xml
file within the xml directory of the skin. The file has the following "schema":
see the examples section and the list of available tags for concrete details.
The following example illustrates the simplest possible skin timer. This timer is completely manual (it has to be manually started and stopped):
This timer can be controlled from your skin by executing the Skin.TimerStart(mymanualtimer)
builtin or Skin.TimerStop(mymanualtimer)
builtin. You can define the visibility of skin elements based on the internal properties of the timer, such as the fact that the timer is active/running using Skin.TimerIsRunning(mymanualtimer)
info or depending on the elapsed time (e.g. 5 seconds) using the Integer.IsGreaterOrEqual(Skin.TimerElapsedSecs(mymanualtimer),5) info.
The following timer is a variation of the previous timer but with the added ability of being automatically stopped by the skinning engine after a maximum of elapsed 5 seconds without having to issue the Skin.TimerStop(mymanualtimer)
builtin:
This type of timer is particularly useful if you want to automatically close a specific window (or triggering a close animation) after x time has elapsed, while guaranteeing the timer is also stopped. See the example below:
The following timer presents a notification (for 1 sec) whenever the timer is activated or deactivated:
The following timer is an example of a completely automatic timer. The timer is automatically activated or deactivated based on the value of boolean info expressions. In this particular example, the timer is automatically started whenever the Player is playing a file (if not already running). It is stopped if there is no file being played (and of course if previously running). Since the timer can be activated/deactivated multiple times, reset="true"
ensures the timer is always reset to 0 on each start operation. Whenever the timer is started or stopped, notifications are issued.
In certain situations you might want to reset your timer without having to stop and start. For instance, if you want to stop the timer after 5 seconds but have the timer resetting to 0 seconds if the user provides some input to Kodi. For such cases the <reset/>
condition can be used:
Finer conditional granularity can also be applied to the onstop
or onstart
actions. This allows the skinner to create generic timers which respect a limited set of conditions but trigger different actions depending on a condition applied only to the action. The following timer plays the trailer of a given item when the user is in the videos window, the item has a trailer, the player is not playing and the global idle time is greater than 3 seconds. As you can see, the first action (notification) is triggered for any item. The actual playback, on the other hand, will only play if the focused item has the label "MyAwesomeMovie".
Skin timers have the following available tags:
Tag | Description |
---|---|
name | The unique name of the timer. The name is used as the id of the timer, hence needs to be unique. (required) |
description | The description of the timer, a helper string. (optional) |
start | An info bool expression that the skinning engine should use to automatically start the timer (optional) |
reset | An info bool expression that the skinning engine should use to automatically reset the timer (optional) |
stop | An info bool expression that the skinning engine should use to automatically stop the timer (optional) |
onstart | A builtin function that the skinning engine should execute when the timer is started (optional)(can be repeated). Supports an additional "condition" as element attribute. |
onstop | A builtin function that the skinning engine should execute when the timer is stopped (optional)(can be repeated). Supports an additional "condition" as element attribute. |