Class: kodi::addon::CInstanceScreensaver
Screensaver add-on instance
A screensaver is a Kodi addon that fills the screen with moving images or patterns when the computer is not in use. Initially designed to prevent phosphor burn-in on CRT and plasma computer monitors (hence the name), screensavers are now used primarily for entertainment, security or to display system status information.
Include the header #include <kodi/addon-instance/ScreenSaver.h> to use this class.
This interface allows the creating of screensavers for Kodi, based upon DirectX or/and OpenGL rendering with C++
code.
The interface is small and easy usable. It has three functions:
Start()
- Called on creation
Render()
- Called at render time
Stop()
- Called when the screensaver has no work
Additionally, there are several other functions available in which the child class can ask about the current hardware, including the device, display and several other parts.
Here is an example of what the addon.xml.in
would look like for an screensaver addon:
<?xml version="1.0" encoding="UTF-8"?>
<addon
id="screensaver.myspecialnamefor"
version="1.0.0"
name="My special screensaver addon"
provider-name="Your Name">
<requires>@ADDON_DEPENDS@</requires>
<extension
point="xbmc.ui.screensaver"
library_@PLATFORM@="@LIBRARY_FILENAME@"/>
<extension point="xbmc.addon.metadata">
<summary lang="en_GB">My screensaver addon</summary>
<description lang="en_GB">My screensaver addon description</description>
<platform>@PLATFORM@</platform>
</extension>
</addon>
Description to screensaver related addon.xml values:
Name | Description |
point | Addon type specification
At all addon types and for this kind always "xbmc.ui.screensaver". |
library_@PLATFORM@ | Sets the used library name, which is automatically set by cmake at addon build. |
Here is an example of the minimum required code to start a screensaver:
#include <kodi/addon-instance/Screensaver.h>
{
public:
CMyScreenSaver();
bool Start() override;
void Render() override;
};
CMyScreenSaver::CMyScreenSaver()
{
...
}
bool CMyScreenSaver::Start()
{
...
return true;
}
void CMyScreenSaver::Render()
{
...
}
ADDONCREATOR(CMyScreenSaver)
Definition: AddonBase.h:322
Definition: Screensaver.h:194
Here is another example where the screensaver is used together with other instance types:
#include <kodi/addon-instance/Screensaver.h>
{
public:
CMyScreenSaver(KODI_HANDLE instance, const std::string& version);
bool Start() override;
void Render() override;
};
CMyScreenSaver::CMyScreenSaver(KODI_HANDLE instance, const std::string& version)
: CInstanceScreensaver(instance, version)
{
...
}
bool CMyScreenSaver::Start()
{
...
return true;
}
void CMyScreenSaver::Render()
{
...
}
{
public:
CMyAddon() = default;
const std::string& instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance) override;
};
const std::string& instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance)
{
{
addonInstance = new CMyScreenSaver(instance, version);
}
else if (...)
{
...
}
}
ADDONCREATOR(CMyAddon)
@ ADDON_LOG_INFO
1 : To include information messages in the log file.
Definition: addon_base.h:177
ADDON_STATUS
Definition: addon_base.h:128
@ ADDON_STATUS_OK
For everything OK and no error.
Definition: addon_base.h:130
@ ADDON_STATUS_UNKNOWN
Unknown and incomprehensible error.
Definition: addon_base.h:142
@ ADDON_INSTANCE_SCREENSAVER
PVR client instance, see kodi::addon::CInstanceScreensaver.
Definition: versions.h:235
virtual ADDON_STATUS CreateInstance(int instanceType, const std::string &instanceID, KODI_HANDLE instance, const std::string &version, KODI_HANDLE &addonInstance)
Instance created.
Definition: AddonBase.h:481
void ATTRIBUTE_HIDDEN Log(const AddonLog loglevel, const char *format,...)
Add a message to Kodi's log.
Definition: AddonBase.h:749
The destruction of the example class CMyScreenSaver
is called from Kodi's header. Manually deleting the add-on instance is not required.
◆ CInstanceScreensaver() [1/2]
Screensaver class constructor.
Used by an add-on that only supports screensavers.
◆ CInstanceScreensaver() [2/2]
Screensaver class constructor used to support multiple instance types.
- Parameters
-
[in] | instance | The instance value given to kodi::addon::CAddonBase::CreateInstance(...) . |
[in] | kodiVersion | [opt] Version used in Kodi for this instance, to allow compatibility to older Kodi versions. |
- Note
- Recommended to set
kodiVersion
.
Here's example about the use of this:
{
public:
CMyScreenSaver(KODI_HANDLE instance, const std::string& kodiVersion)
{
...
}
...
};
const std::string& instanceID,
KODI_HANDLE instance,
const std::string& version,
KODI_HANDLE& addonInstance)
{
addonInstance = new CMyScreenSaver(instance, version);
}
CInstanceScreensaver()
Screensaver class constructor.
Definition: Screensaver.h:202
◆ ~CInstanceScreensaver()
◆ Start()
Used to notify the screensaver that it has been started.
- Returns
- true if the screensaver was started successfully, false otherwise
◆ Stop()
Used to inform the screensaver that the rendering control was stopped.
◆ Render()
Used to indicate when the add-on should render.