Kodi Documentation 18.0
Kodi is an open source media player and entertainment hub.

\cpp_class{ kodi::addon::CInstanceScreensaver } Screensaver add-on instance More...

Modules

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

Functions

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

Detailed Description

\cpp_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 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)
#define ADDONCREATOR(AddonClass)
Definition: AddonBase.h:665
Add-on main instance class.
Definition: AddonBase.h:292
Definition: kodi-addon-dev-kit/include/kodi/addon-instance/Screensaver.h:222

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

class CMyScreenSaver : public ::kodi::addon::CInstanceScreensaver
{
public:
CMyScreenSaver(KODI_HANDLE instance);
bool Start() override;
void Render() override;
};
CMyScreenSaver::CMyScreenSaver(KODI_HANDLE instance)
: CInstanceScreensaver(instance)
{
...
}
bool CMyScreenSaver::Start()
{
...
return true;
}
void CMyScreenSaver::Render()
{
...
}
/*----------------------------------------------------------------------*&zwj;/
class CMyAddon : public ::kodi::addon::CAddonBase
{
public:
CMyAddon() { }
ADDON_STATUS CreateInstance(int instanceType,
std::string instanceID,
KODI_HANDLE instance,
KODI_HANDLE& addonInstance) override;
};
/* If you use only one instance in your add-on, can be instanceType and
* instanceID ignored *&zwj;/
ADDON_STATUS CMyAddon::CreateInstance(int instanceType,
std::string instanceID,
KODI_HANDLE instance,
KODI_HANDLE& addonInstance)
{
if (instanceType == ADDON_INSTANCE_SCREENSAVER)
{
kodi::Log(ADDON_LOG_NOTICE, "Creating my Screensaver");
addonInstance = new CMyScreenSaver(instance);
return ADDON_STATUS_OK;
}
else if (...)
{
...
}
return ADDON_STATUS_UNKNOWN;
}
ADDONCREATOR(CMyAddon)
void * KODI_HANDLE
Standard undefined pointer handle.
Definition: AddonBase.h:69

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 ( KODI_HANDLE  instance)
inlineexplicit

Screensaver class constructor used to support multiple instance types.

Parameters
[in]instanceThe instance value given to kodi::addon::CAddonBase::CreateInstance(...).
Warning
Only use instance from the CreateInstance call

◆ Render()

virtual void kodi::addon::CInstanceScreensaver::Render ( void  )
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.