Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches

Class: kodi::addon::CInstanceScreensaver

Screensaver add-on instance More...

Topics

 Information functions
 To get info about the device, display and several other parts
 

Functions

 kodi::addon::CInstanceScreensaver::CInstanceScreensaver ()
 Screensaver class constructor.
 
 kodi::addon::CInstanceScreensaver::CInstanceScreensaver (const IInstanceInfo &instance)
 Screensaver class constructor used to support multiple instance types.
 
 kodi::addon::CInstanceScreensaver::~CInstanceScreensaver () override=default
 Destructor.
 
virtual bool kodi::addon::CInstanceScreensaver::Start ()
 Used to notify the screensaver that it has been started.
 
virtual void kodi::addon::CInstanceScreensaver::Stop ()
 Used to inform the screensaver that the rendering control was stopped.
 
virtual void kodi::addon::CInstanceScreensaver::Render ()
 Used to indicate when the add-on should render.
 

Detailed Description

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:

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.
Remarks
For more detailed description of the addon.xml, see also https://kodi.wiki/view/Addon.xml.

Here is an example of the minimum required code to start a screensaver:

class CMyScreenSaver : public kodi::addon::CAddonBase,
{
public:
CMyScreenSaver();
bool Start() override;
void Render() override;
};
CMyScreenSaver::CMyScreenSaver()
{
...
}
bool CMyScreenSaver::Start()
{
...
return true;
}
void CMyScreenSaver::Render()
{
...
}
ADDONCREATOR(CMyScreenSaver)
Definition kodi-dev-kit/include/kodi/AddonBase.h:583
Definition kodi-dev-kit/include/kodi/addon-instance/ScreenSaver.h:188
#define ADDONCREATOR(AddonClass)
Definition kodi-dev-kit/include/kodi/AddonBase.h:1855

Here is another example where the screensaver is used together with other instance types:

class CMyScreenSaver : public kodi::addon::CInstanceScreensaver
{
public:
CMyScreenSaver(const kodi::addon::IInstanceInfo& instance);
bool Start() override;
void Render() override;
};
CMyScreenSaver::CMyScreenSaver(const kodi::addon::IInstanceInfo& instance)
: CInstanceScreensaver(instance)
{
...
}
bool CMyScreenSaver::Start()
{
...
return true;
}
void CMyScreenSaver::Render()
{
...
}
//----------------------------------------------------------------------
class CMyAddon : public kodi::addon::CAddonBase
{
public:
CMyAddon() = default;
};
// If you use only one instance in your add-on, can be instanceType and
// instanceID ignored
ADDON_STATUS CMyAddon::CreateInstance(const kodi::addon::IInstanceInfo& instance,
{
{
kodi::Log(ADDON_LOG_INFO, "Creating my Screensaver");
hdl = new CMyScreenSaver(instance, version);
}
else if (...)
{
...
}
}
ADDONCREATOR(CMyAddon)
void * KODI_ADDON_INSTANCE_HDL
Definition addon_base.h:121
KODI_ADDON_HDL * hdl
Definition addon_base.h:344
Definition kodi-dev-kit/include/kodi/AddonBase.h:306
@ ADDON_LOG_INFO
1 : To include information messages in the log file.
Definition addon_base.h:187
ADDON_STATUS
Definition addon_base.h:138
@ ADDON_STATUS_OK
For everything OK and no error.
Definition addon_base.h:140
@ ADDON_STATUS_UNKNOWN
Unknown and incomprehensible error.
Definition addon_base.h:152
@ ADDON_INSTANCE_SCREENSAVER
Screen saver instance, see kodi::addon::CInstanceScreensaver.
Definition versions.h:236
virtual ADDON_STATUS CreateInstance(const kodi::addon::IInstanceInfo &instance, KODI_ADDON_INSTANCE_HDL &hdl)
Instance created.
Definition kodi-dev-kit/include/kodi/AddonBase.h:732
void ATTR_DLL_LOCAL Log(const ADDON_LOG loglevel, const char *format,...)
Add a message to Kodi's log.
Definition kodi-dev-kit/include/kodi/AddonBase.h:1746
Definition addon_base.h:268

The destruction of the example class CMyScreenSaver is called from Kodi's header. Manually deleting the add-on instance is not required.

Function Documentation

◆ CInstanceScreensaver() [1/2]

kodi::addon::CInstanceScreensaver::CInstanceScreensaver ( )
inline

Screensaver class constructor.

Used by an add-on that only supports screensavers.

◆ CInstanceScreensaver() [2/2]

kodi::addon::CInstanceScreensaver::CInstanceScreensaver ( const IInstanceInfo & instance)
inlineexplicit

Screensaver class constructor used to support multiple instance types.

Parameters
[in]instanceThe 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:

class CMyScreenSaver : public kodi::addon::CInstanceScreensaver
{
public:
CMyScreenSaver(KODI_HANDLE instance, const std::string& kodiVersion)
: kodi::addon::CInstanceScreensaver(instance, kodiVersion)
{
...
}
...
};
ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
const std::string& instanceID,
const std::string& version,
KODI_HANDLE& addonInstance)
{
kodi::Log(ADDON_LOG_INFO, "Creating my screensaver");
addonInstance = new CMyScreenSaver(instance, version);
}
void * KODI_HANDLE
Standard undefined pointer handle.
Definition addon_base.h:291
Definition addons/kodi-dev-kit/include/kodi/addon-instance/AudioDecoder.h:21

◆ Render()

virtual void kodi::addon::CInstanceScreensaver::Render ( )
inlinevirtual

Used to indicate when the add-on should render.

◆ Start()

virtual bool kodi::addon::CInstanceScreensaver::Start ( )
inlinevirtual

Used to notify the screensaver that it has been started.

Returns
true if the screensaver was started successfully, false otherwise

◆ Stop()

virtual void kodi::addon::CInstanceScreensaver::Stop ( )
inlinevirtual

Used to inform the screensaver that the rendering control was stopped.

◆ ~CInstanceScreensaver()

kodi::addon::CInstanceScreensaver::~CInstanceScreensaver ( )
overridedefault

Destructor.