Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
KODI::PLAYLIST::CPlayListPlayer Class Reference

#include <PlayListPlayer.h>

Inheritance diagram for KODI::PLAYLIST::CPlayListPlayer:
IMsgTargetCallback KODI::MESSAGING::IMessageTarget

Public Member Functions

 CPlayListPlayer (void)
 
 ~CPlayListPlayer (void) override
 
bool OnMessage (CGUIMessage &message) override
 
int GetMessageMask () override
 Should return the message mask that it wishes to receive messages for.
 
void OnApplicationMessage (KODI::MESSAGING::ThreadMessage *pMsg) override
 This gets called whenever a message matching the registered message mask is processed.
 
bool PlayNext (int offset=1, bool autoPlay=false)
 Play the next (or another) entry in the current playlist.
 
bool PlayPrevious ()
 Play the previous entry in the current playlist.
 
bool PlayItemIdx (int itemIdx)
 
bool Play ()
 
bool Play (const CFileItemPtr &pItem, const std::string &player, bool forceSelection=false)
 Creates a new playlist for an item and starts playing it.
 
bool Play (int index, const std::string &player, bool replace=false, bool playPreviousOnFail=false, bool forceSelection=false)
 Start playing a particular entry in the current playlist.
 
int GetCurrentItemIdx () const
 Returns the index of the current item in active playlist.
 
void SetCurrentItemIdx (int index)
 Change the current item in the active playlist.
 
int GetNextItemIdx ()
 
int GetNextItemIdx (int offset) const
 Get the index in the playlist that is offset away from the current index in the current playlist. Obeys any repeat settings (eg repeat one will return the current index regardless of offset)
 
void SetCurrentPlaylist (Id playlistId)
 Set the active playlist.
 
Id GetCurrentPlaylist () const
 Get the currently active playlist.
 
CPlayListGetPlaylist (Id playlistId)
 Get a particular playlist object.
 
const CPlayListGetPlaylist (Id playlistId) const
 
int RemoveDVDItems ()
 Removes any item from all playlists located on a removable share.
 
void Reset ()
 Resets the current song and unplayable counts. Does not alter the active playlist.
 
void ClearPlaylist (Id playlistId)
 
void Clear ()
 
void SetShuffle (Id playlistId, bool shuffle, bool notify=false)
 Set shuffle state of a playlist. If the shuffle state changes, the playlist is shuffled or unshuffled. Has no effect if Party Mode is enabled.
 
bool IsShuffled (Id playlistId) const
 Return whether a playlist is shuffled. If partymode is enabled, this always returns false.
 
bool HasPlayedFirstFile () const
 Return whether or not something has been played yet from the current playlist.
 
void SetRepeat (Id playlistId, RepeatState state, bool notify=false)
 Set repeat state of a playlist. If called while in Party Mode, repeat is disabled.
 
RepeatState GetRepeat (Id playlistId) const
 
void Add (Id playlistId, const CPlayList &playlist)
 
void Add (Id playlistId, const CFileItemPtr &pItem)
 
void Add (Id playlistId, const CFileItemList &items)
 
void Insert (Id playlistId, const CPlayList &playlist, int iIndex)
 
void Insert (Id playlistId, const CFileItemPtr &pItem, int iIndex)
 
void Insert (Id playlistId, const CFileItemList &items, int iIndex)
 
void Remove (Id playlistId, int iPosition)
 
void Swap (Id playlistId, int indexItem1, int indexItem2)
 
bool IsSingleItemNonRepeatPlaylist () const
 
bool OnAction (const CAction &action)
 
- Public Member Functions inherited from IMsgTargetCallback
virtual ~IMsgTargetCallback ()=default
 
- Public Member Functions inherited from KODI::MESSAGING::IMessageTarget
virtual ~IMessageTarget ()=default
 

Protected Member Functions

bool Repeated (Id playlistId) const
 Returns true if the given is set to repeat all.
 
bool RepeatedOne (Id playlistId) const
 Returns true if the given is set to repeat one.
 
void ReShuffle (Id playlistId, int iPosition)
 
void AnnouncePropertyChanged (Id playlistId, const std::string &strProperty, const CVariant &value)
 

Protected Attributes

bool m_bPlayedFirstFile
 
bool m_bPlaybackStarted
 
int m_iFailedSongs
 
std::chrono::time_point< std::chrono::steady_clock > m_failedSongsStart
 
int m_iCurrentSong
 
Id m_iCurrentPlayList {Id::TYPE_NONE}
 
CPlayListm_PlaylistMusic
 
CPlayListm_PlaylistVideo
 
CPlayListm_PlaylistEmpty
 
std::map< Id, RepeatStatem_repeatState
 

Constructor & Destructor Documentation

◆ CPlayListPlayer()

KODI::PLAYLIST::CPlayListPlayer::CPlayListPlayer ( void )

◆ ~CPlayListPlayer()

KODI::PLAYLIST::CPlayListPlayer::~CPlayListPlayer ( void )
override

Member Function Documentation

◆ Add() [1/3]

void KODI::PLAYLIST::CPlayListPlayer::Add ( Id playlistId,
const CFileItemList & items )

◆ Add() [2/3]

void KODI::PLAYLIST::CPlayListPlayer::Add ( Id playlistId,
const CFileItemPtr & pItem )

◆ Add() [3/3]

void KODI::PLAYLIST::CPlayListPlayer::Add ( Id playlistId,
const CPlayList & playlist )

◆ AnnouncePropertyChanged()

void KODI::PLAYLIST::CPlayListPlayer::AnnouncePropertyChanged ( Id playlistId,
const std::string & strProperty,
const CVariant & value )
protected

◆ Clear()

void KODI::PLAYLIST::CPlayListPlayer::Clear ( )

◆ ClearPlaylist()

void KODI::PLAYLIST::CPlayListPlayer::ClearPlaylist ( Id playlistId)

◆ GetCurrentItemIdx()

int KODI::PLAYLIST::CPlayListPlayer::GetCurrentItemIdx ( ) const

Returns the index of the current item in active playlist.

Returns
Current item in the active playlist.
See also
SetCurrentItemIdx

◆ GetCurrentPlaylist()

Id KODI::PLAYLIST::CPlayListPlayer::GetCurrentPlaylist ( ) const

Get the currently active playlist.

Returns
Id of playlist
See also
SetCurrentPlaylist, GetPlaylist

◆ GetMessageMask()

int KODI::PLAYLIST::PLAYLIST::CPlayListPlayer::GetMessageMask ( )
overridevirtual

Should return the message mask that it wishes to receive messages for.

The message mask is defined in "messaging/ApplicationMessenger.h" pick the next one available when creating a new

Implements KODI::MESSAGING::IMessageTarget.

◆ GetNextItemIdx() [1/2]

int KODI::PLAYLIST::CPlayListPlayer::GetNextItemIdx ( )

◆ GetNextItemIdx() [2/2]

int KODI::PLAYLIST::CPlayListPlayer::GetNextItemIdx ( int offset) const

Get the index in the playlist that is offset away from the current index in the current playlist. Obeys any repeat settings (eg repeat one will return the current index regardless of offset)

Returns
the index of the entry, or -1 if there is no current playlist. There is no guarantee that the returned index is valid.

◆ GetPlaylist() [1/2]

CPlayList & KODI::PLAYLIST::CPlayListPlayer::GetPlaylist ( Id playlistId)

Get a particular playlist object.

Parameters
idId of playlist
Returns
A reference to the CPlayList object.
See also
GetCurrentPlaylist

◆ GetPlaylist() [2/2]

const CPlayList & KODI::PLAYLIST::CPlayListPlayer::GetPlaylist ( Id playlistId) const

◆ GetRepeat()

RepeatState KODI::PLAYLIST::CPlayListPlayer::GetRepeat ( Id playlistId) const

◆ HasPlayedFirstFile()

bool KODI::PLAYLIST::CPlayListPlayer::HasPlayedFirstFile ( ) const

Return whether or not something has been played yet from the current playlist.

Returns
true if something has been played, false otherwise.

◆ Insert() [1/3]

void KODI::PLAYLIST::CPlayListPlayer::Insert ( Id playlistId,
const CFileItemList & items,
int iIndex )

◆ Insert() [2/3]

void KODI::PLAYLIST::CPlayListPlayer::Insert ( Id playlistId,
const CFileItemPtr & pItem,
int iIndex )

◆ Insert() [3/3]

void KODI::PLAYLIST::CPlayListPlayer::Insert ( Id playlistId,
const CPlayList & playlist,
int iIndex )

◆ IsShuffled()

bool KODI::PLAYLIST::CPlayListPlayer::IsShuffled ( Id playlistId) const

Return whether a playlist is shuffled. If partymode is enabled, this always returns false.

Parameters
playlistthe playlist to query for shuffle state, PLAYLIST::TYPE_MUSIC or PLAYLIST::TYPE_VIDEO.
Returns
true if the given playlist is shuffled and party mode isn't enabled, false otherwise.
See also
SetShuffle

◆ IsSingleItemNonRepeatPlaylist()

bool KODI::PLAYLIST::CPlayListPlayer::IsSingleItemNonRepeatPlaylist ( ) const

◆ OnAction()

bool KODI::PLAYLIST::CPlayListPlayer::OnAction ( const CAction & action)

◆ OnApplicationMessage()

void KODI::PLAYLIST::PLAYLIST::CPlayListPlayer::OnApplicationMessage ( KODI::MESSAGING::ThreadMessage * msg)
overridevirtual

This gets called whenever a message matching the registered message mask is processed.

There are no ordering guarantees here so implementations should never rely on a certain ordering of messages.

Cleaning up any pointers stored in the message payload is not specified and is decided by the implementer of the message. In general prefer to delete any data in this method to keep the callsites cleaner and simpler but if data is to be passed back it's perfectly valid to handle it any way that fits the situation as long as it's documented along with the message.

To return a simple value the result parameter of

See also
ThreadMessage can be used as it will be used as the return value for
CApplicationMessenger::SendMsg. It is up to the implementer to decide if this is to be used and it should be documented along with any new message implemented.

Implements KODI::MESSAGING::IMessageTarget.

◆ OnMessage()

bool KODI::PLAYLIST::CPlayListPlayer::OnMessage ( CGUIMessage & message)
overridevirtual

Implements IMsgTargetCallback.

◆ Play() [1/3]

bool KODI::PLAYLIST::CPlayListPlayer::Play ( )

◆ Play() [2/3]

bool KODI::PLAYLIST::CPlayListPlayer::Play ( const CFileItemPtr & pItem,
const std::string & player,
bool forceSelection = false )

Creates a new playlist for an item and starts playing it.

Parameters
pItemThe item to play.
playerThe player name.
forceSelectionfor Blurays, force simple menu to change playlist (default to false)
Returns
True if has success, otherwise false.

◆ Play() [3/3]

bool KODI::PLAYLIST::CPlayListPlayer::Play ( int index,
const std::string & player,
bool replace = false,
bool playPreviousOnFail = false,
bool forceSelection = false )

Start playing a particular entry in the current playlist.

Parameters
indexthe index of the item to play. This value is modified to ensure it lies within the current playlist.
replacewhether this item should replace the currently playing item. See CApplication::PlayFile (defaults to false).
playPreviousOnFailwhether to go back to the previous item if playback fails (default to false)
forceSelectionfor Blurays, force simple menu to change playlist (default to false)
Todo
  • move the above failure logic and the below success logic to callbacks instead so we don't rely on the return value of PlayFile()

◆ PlayItemIdx()

bool KODI::PLAYLIST::CPlayListPlayer::PlayItemIdx ( int itemIdx)

◆ PlayNext()

bool KODI::PLAYLIST::CPlayListPlayer::PlayNext ( int offset = 1,
bool autoPlay = false )

Play the next (or another) entry in the current playlist.

Parameters
offsetThe offset from the current entry (defaults to 1, i.e. the next entry).
autoPlayWhether we should start playing if not already (defaults to false).

◆ PlayPrevious()

bool KODI::PLAYLIST::CPlayListPlayer::PlayPrevious ( )

Play the previous entry in the current playlist.

See also
PlayNext

◆ Remove()

void KODI::PLAYLIST::CPlayListPlayer::Remove ( Id playlistId,
int iPosition )

◆ RemoveDVDItems()

int KODI::PLAYLIST::CPlayListPlayer::RemoveDVDItems ( )

Removes any item from all playlists located on a removable share.

Returns
Number of items removed from PLAYLIST::TYPE_MUSIC and PLAYLIST::TYPE_VIDEO

◆ Repeated()

bool KODI::PLAYLIST::CPlayListPlayer::Repeated ( Id playlistId) const
protected

Returns true if the given is set to repeat all.

Parameters
playlistPlaylist to be query
Returns
true if the given playlist is set to repeat all, false otherwise.

◆ RepeatedOne()

bool KODI::PLAYLIST::CPlayListPlayer::RepeatedOne ( Id playlistId) const
protected

Returns true if the given is set to repeat one.

Parameters
playlistPlaylist to be query
Returns
true if the given playlist is set to repeat one, false otherwise.

◆ Reset()

void KODI::PLAYLIST::CPlayListPlayer::Reset ( )

Resets the current song and unplayable counts. Does not alter the active playlist.

◆ ReShuffle()

void KODI::PLAYLIST::CPlayListPlayer::ReShuffle ( Id playlistId,
int iPosition )
protected

◆ SetCurrentItemIdx()

void KODI::PLAYLIST::CPlayListPlayer::SetCurrentItemIdx ( int index)

Change the current item in the active playlist.

Parameters
indexitem index in playlist. Set only if the index is within the range of the current playlist.
See also
GetCurrentItemIdx

◆ SetCurrentPlaylist()

void KODI::PLAYLIST::CPlayListPlayer::SetCurrentPlaylist ( Id playlistId)

Set the active playlist.

Parameters
idId of playlist
See also
GetCurrentPlaylist

◆ SetRepeat()

void KODI::PLAYLIST::CPlayListPlayer::SetRepeat ( Id playlistId,
RepeatState state,
bool notify = false )

Set repeat state of a playlist. If called while in Party Mode, repeat is disabled.

Parameters
playlistthe playlist to set repeat state for, PLAYLIST::TYPE_MUSIC or PLAYLIST::TYPE_VIDEO.
stateset to RepeatState::NONE, RepeatState::ONE or RepeatState::ALL
notifynotify the user with a Toast notification
See also
GetRepeat

◆ SetShuffle()

void KODI::PLAYLIST::CPlayListPlayer::SetShuffle ( Id playlistId,
bool shuffle,
bool notify = false )

Set shuffle state of a playlist. If the shuffle state changes, the playlist is shuffled or unshuffled. Has no effect if Party Mode is enabled.

Parameters
playlistthe playlist to (un)shuffle, PLAYLIST::TYPE_MUSIC or PLAYLIST::TYPE_VIDEO.
shuffleset true to shuffle, false to unshuffle.
notifynotify the user with a Toast notification (defaults to false)
See also
IsShuffled

◆ Swap()

void KODI::PLAYLIST::CPlayListPlayer::Swap ( Id playlistId,
int indexItem1,
int indexItem2 )

Member Data Documentation

◆ m_bPlaybackStarted

bool KODI::PLAYLIST::CPlayListPlayer::m_bPlaybackStarted
protected

◆ m_bPlayedFirstFile

bool KODI::PLAYLIST::CPlayListPlayer::m_bPlayedFirstFile
protected

◆ m_failedSongsStart

std::chrono::time_point<std::chrono::steady_clock> KODI::PLAYLIST::CPlayListPlayer::m_failedSongsStart
protected

◆ m_iCurrentPlayList

Id KODI::PLAYLIST::CPlayListPlayer::m_iCurrentPlayList {Id::TYPE_NONE}
protected

◆ m_iCurrentSong

int KODI::PLAYLIST::CPlayListPlayer::m_iCurrentSong
protected

◆ m_iFailedSongs

int KODI::PLAYLIST::CPlayListPlayer::m_iFailedSongs
protected

◆ m_PlaylistEmpty

CPlayList* KODI::PLAYLIST::CPlayListPlayer::m_PlaylistEmpty
protected

◆ m_PlaylistMusic

CPlayList* KODI::PLAYLIST::CPlayListPlayer::m_PlaylistMusic
protected

◆ m_PlaylistVideo

CPlayList* KODI::PLAYLIST::CPlayListPlayer::m_PlaylistVideo
protected

◆ m_repeatState


The documentation for this class was generated from the following files: