Kodi Development  20.0
for Binary and Script based Add-Ons
3. Channel Groups (optional)

Detailed Description

Bring in this functions if you have set supportsChannelGroups to true
This is used to divide available addon channels into groups, which can then be selected by the user.


Channel group parts in interface:
Copy this to your project and extend with your parts or leave functions complete away where not used or supported.

Header parts:

PVR_ERROR GetChannelGroupsAmount(int& amount) override;
Definition: ChannelGroups.h:38
Definition: ChannelGroups.h:238
Definition: ChannelGroups.h:103
PVR_ERROR
Definition: pvr_general.h:35
virtual PVR_ERROR GetChannelGroupMembers(const kodi::addon::PVRChannelGroup &group, kodi::addon::PVRChannelGroupMembersResultSet &results)
Get a list of members on a group.
Definition: PVR.h:1248
virtual PVR_ERROR GetChannelGroupsAmount(int &amount)
Get the total amount of channel groups on the backend if it supports channel groups.
Definition: PVR.h:1137
virtual PVR_ERROR GetChannelGroups(bool radio, kodi::addon::PVRChannelGroupsResultSet &results)
Get a list of available channel groups on addon.
Definition: PVR.h:1185

Source parts:

PVR_ERROR CMyInstance::GetChannelGroupsAmount(int& amount)
{
}
PVR_ERROR CMyInstance::GetChannelGroups(bool radio, kodi::addon::PVRChannelGroupsResultSet& results)
{
}
PVR_ERROR CMyInstance::GetChannelGroupMembers(const kodi::addon::PVRChannelGroup& group, kodi::addon::PVRChannelGroupMembersResultSet& results)
{
}
@ PVR_ERROR_NOT_IMPLEMENTED
-2 : The method that Kodi called is not implemented by the add-on.
Definition: pvr_general.h:43

Modules

 Group header include
 
 Group source include
 

Function Documentation

◆ GetChannelGroupsAmount()

virtual PVR_ERROR GetChannelGroupsAmount ( int &  amount)
inlinevirtual

Get the total amount of channel groups on the backend if it supports channel groups.

Parameters
[out]amountThe total amount of channel groups on the backend
Returns
PVR_ERROR_NO_ERROR if the amount has been fetched successfully.
Remarks
Required if supportsChannelGroups is set to true.

◆ GetChannelGroups()

virtual PVR_ERROR GetChannelGroups ( bool  radio,
kodi::addon::PVRChannelGroupsResultSet results 
)
inlinevirtual

Get a list of available channel groups on addon.

Request the list of all channel groups from the backend if it supports channel groups.

Parameters
[in]radioTrue to get the radio channel groups, false to get the TV channel groups.
[out]resultsList of available groups on addon defined with class PVRChannelGroup, them transferred with class PVRChannelGroupsResultSet.
Returns
PVR_ERROR_NO_ERROR if the list has been fetched successfully.

The following table contains values that can be set with class PVRChannelGroup :

Name Type Set call Get call Usage
Group name std::string SetGroupName GetGroupName required to set
Is radio bool SetIsRadio GetIsRadio required to set
Position unsigned int SetPosition GetPosition optional

Remarks
Required if supportsChannelGroups is set to true.

Example:

...
PVR_ERROR CMyPVRInstance::GetChannelGroups(bool radio, kodi::addon::PVRChannelGroupsResultSet& groups)
{
group.SetIsRadio(false);
group.SetGroupName("My group name");
group.SetPosition(1);
...
// Give it now to Kodi
results.Add(group);
}
...
void SetPosition(unsigned int position)
optional Sort position of the group (0 indicates that the backend doesn't support sorting of groups).
Definition: ChannelGroups.h:81
void SetIsRadio(bool isRadio)
required true If this is a radio channel group, false otherwise.
Definition: ChannelGroups.h:73
void SetGroupName(const std::string &groupName)
required Name of this channel group.
Definition: ChannelGroups.h:63
@ PVR_ERROR_NO_ERROR
0 : No error occurred.
Definition: pvr_general.h:37

◆ GetChannelGroupMembers()

virtual PVR_ERROR GetChannelGroupMembers ( const kodi::addon::PVRChannelGroup group,
kodi::addon::PVRChannelGroupMembersResultSet results 
)
inlinevirtual

Get a list of members on a group.

Request the list of all group members of a group from the backend if it supports channel groups.

Parameters
[in]groupThe group to get the members for.
[out]resultsList of available group member channels defined with class PVRChannelGroupMember, them transferred with PVRChannelGroupMembersResultSet.
Returns
PVR_ERROR_NO_ERROR if the list has been fetched successfully.

The following table contains values that can be set with class PVRChannelGroupMember :

Name Type Set call Get call Usage
Group name std::string SetGroupName GetGroupName required to set
Channel unique id unsigned int SetChannelUniqueId GetChannelUniqueId required to set
Channel Number unsigned int SetChannelNumber GetChannelNumber optional
Sub channel number unsigned int SetSubChannelNumber GetSubChannelNumber optional
Order int SetOrder GetOrder optional

Remarks
Required if supportsChannelGroups is set to true.

Example:

...
PVR_ERROR CMyPVRInstance::GetChannelGroupMembers(const kodi::addon::PVRChannelGroup& group,
{
for (const auto& myGroup : m_myGroups)
{
if (myGroup.strGroupName == group.GetGroupName())
{
for (unsigned int iChannelPtr = 0; iChannelPtr < myGroup.members.size(); iChannelPtr++)
{
int iId = myGroup.members.at(iChannelPtr) - 1;
if (iId < 0 || iId > (int)m_channels.size() - 1)
continue;
PVRDemoChannel &channel = m_channels.at(iId);
kodiGroupMember.SetGroupName(group.GetGroupName());
kodiGroupMember.SetChannelUniqueId(channel.iUniqueId);
kodiGroupMember.SetChannelNumber(channel.iChannelNumber);
kodiGroupMember.SetSubChannelNumber(channel.iSubChannelNumber);
results.Add(kodiGroupMember);
}
}
}
}
...
Definition: ChannelGroups.h:149
std::string GetGroupName() const
To get with SetGroupName changed values.
Definition: ChannelGroups.h:69
void SetChannelNumber(unsigned int channelNumber)
optional Channel number within the group.
Definition: ChannelGroups.h:196
void SetSubChannelNumber(unsigned int subChannelNumber)
optional Sub channel number within the group (ATSC).
Definition: ChannelGroups.h:206
void SetChannelUniqueId(unsigned int channelUniqueId)
required Unique id of the member.
Definition: ChannelGroups.h:186
void SetGroupName(const std::string &groupName)
required Name of the channel group to add the channel to.
Definition: ChannelGroups.h:176
void Add(const kodi::addon::PVRChannelGroupMember &tag)
To add and give content from addon to Kodi on related call.
Definition: ChannelGroups.h:254

◆ TriggerChannelGroupsUpdate()

void TriggerChannelGroupsUpdate ( )
inline

Callback to Kodi Function
Request Kodi to update it's list of channel groups.

Remarks
Only called from addon itself