xbmc
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PLAYLIST::CPlayListPlayer Class Reference
Inheritance diagram for PLAYLIST::CPlayListPlayer:
Inheritance graph
[legend]
Collaboration diagram for PLAYLIST::CPlayListPlayer:
Collaboration graph
[legend]

Public Member Functions

bool OnMessage (CGUIMessage &message) override
 
int GetMessageMask () override
 Should return the message mask that it wishes to receive messages for. More...
 
void OnApplicationMessage (KODI::MESSAGING::ThreadMessage *pMsg) override
 This gets called whenever a message matching the registered message mask is processed. More...
 
bool PlayNext (int offset=1, bool autoPlay=false)
 Play the next (or another) entry in the current playlist. More...
 
bool PlayPrevious ()
 Play the previous entry in the current playlist. More...
 
bool PlaySongId (int songId)
 
bool Play ()
 
bool Play (const CFileItemPtr &pItem, const std::string &player)
 Creates a new playlist for an item and starts playing it. More...
 
bool Play (int index, const std::string &player, bool replace=false, bool playPreviousOnFail=false)
 Start playing a particular entry in the current playlist. More...
 
int GetCurrentSong () const
 Returns the index of the current item in active playlist. More...
 
void SetCurrentSong (int index)
 Change the current item in the active playlist. More...
 
int GetNextSong ()
 
int GetNextSong (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) More...
 
void SetCurrentPlaylist (PLAYLIST::Id playlistId)
 Set the active playlist. More...
 
PLAYLIST::Id GetCurrentPlaylist () const
 Get the currently active playlist. More...
 
CPlayListGetPlaylist (PLAYLIST::Id playlistId)
 Get a particular playlist object. More...
 
const CPlayListGetPlaylist (PLAYLIST::Id playlistId) const
 
int RemoveDVDItems ()
 Removes any item from all playlists located on a removable share. More...
 
void Reset ()
 Resets the current song and unplayable counts. Does not alter the active playlist.
 
void ClearPlaylist (PLAYLIST::Id playlistId)
 
void Clear ()
 
void SetShuffle (PLAYLIST::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. More...
 
bool IsShuffled (PLAYLIST::Id playlistId) const
 Return whether a playlist is shuffled. If partymode is enabled, this always returns false. More...
 
bool HasPlayedFirstFile () const
 Return whether or not something has been played yet from the current playlist. More...
 
void SetRepeat (PLAYLIST::Id playlistId, PLAYLIST::RepeatState state, bool notify=false)
 Set repeat state of a playlist. If called while in Party Mode, repeat is disabled. More...
 
PLAYLIST::RepeatState GetRepeat (PLAYLIST::Id playlistId) const
 
void Add (PLAYLIST::Id playlistId, const CPlayList &playlist)
 
void Add (PLAYLIST::Id playlistId, const CFileItemPtr &pItem)
 
void Add (PLAYLIST::Id playlistId, const CFileItemList &items)
 
void Insert (PLAYLIST::Id playlistId, const CPlayList &playlist, int iIndex)
 
void Insert (PLAYLIST::Id playlistId, const CFileItemPtr &pItem, int iIndex)
 
void Insert (PLAYLIST::Id playlistId, const CFileItemList &items, int iIndex)
 
void Remove (PLAYLIST::Id playlistId, int iPosition)
 
void Swap (PLAYLIST::Id playlistId, int indexItem1, int indexItem2)
 
bool IsSingleItemNonRepeatPlaylist () const
 
bool OnAction (const CAction &action)
 

Protected Member Functions

bool Repeated (PLAYLIST::Id playlistId) const
 Returns true if the given is set to repeat all. More...
 
bool RepeatedOne (PLAYLIST::Id playlistId) const
 Returns true if the given is set to repeat one. More...
 
void ReShuffle (PLAYLIST::Id playlistId, int iPosition)
 
void AnnouncePropertyChanged (PLAYLIST::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
 
PLAYLIST::Id m_iCurrentPlayList {PLAYLIST::TYPE_NONE}
 
CPlayListm_PlaylistMusic
 
CPlayListm_PlaylistVideo
 
CPlayListm_PlaylistEmpty
 
std::map< PLAYLIST::Id, PLAYLIST::RepeatState > m_repeatState
 

Member Function Documentation

◆ GetCurrentPlaylist()

Id CPlayListPlayer::GetCurrentPlaylist ( ) const

Get the currently active playlist.

Returns
PLAYLIST::TYPE_NONE, PLAYLIST::TYPE_MUSIC or PLAYLIST::TYPE_VIDEO
See also
SetCurrentPlaylist, GetPlaylist

◆ GetCurrentSong()

int CPlayListPlayer::GetCurrentSong ( ) const

Returns the index of the current item in active playlist.

Returns
Current item in the active playlist.
See also
SetCurrentSong

◆ GetMessageMask()

int 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.

◆ GetNextSong()

int CPlayListPlayer::GetNextSong ( 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()

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

Get a particular playlist object.

Parameters
idValues can be PLAYLIST::TYPE_MUSIC or PLAYLIST::TYPE_VIDEO
Returns
A reference to the CPlayList object.
See also
GetCurrentPlaylist

◆ HasPlayedFirstFile()

bool 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.

◆ IsShuffled()

bool CPlayListPlayer::IsShuffled ( PLAYLIST::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

◆ OnApplicationMessage()

void 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.

◆ Play() [1/2]

bool CPlayListPlayer::Play ( const CFileItemPtr pItem,
const std::string &  player 
)

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

Parameters
pItemThe item to play.
playerThe player name.
Returns
True if has success, otherwise false.

◆ Play() [2/2]

bool CPlayListPlayer::Play ( int  index,
const std::string &  player,
bool  replace = false,
bool  playPreviousOnFail = 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)
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()

◆ PlayNext()

bool 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 CPlayListPlayer::PlayPrevious ( )

Play the previous entry in the current playlist.

See also
PlayNext

◆ RemoveDVDItems()

int 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 CPlayListPlayer::Repeated ( PLAYLIST::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 CPlayListPlayer::RepeatedOne ( PLAYLIST::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.

◆ SetCurrentPlaylist()

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

Set the active playlist.

Parameters
idValues can be PLAYLIST::TYPE_NONE, PLAYLIST::TYPE_MUSIC or PLAYLIST::TYPE_VIDEO
See also
GetCurrentPlaylist

◆ SetCurrentSong()

void CPlayListPlayer::SetCurrentSong ( 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
GetCurrentSong

◆ SetRepeat()

void CPlayListPlayer::SetRepeat ( PLAYLIST::Id  playlistId,
PLAYLIST::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 CPlayListPlayer::SetShuffle ( PLAYLIST::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

Member Data Documentation

◆ m_repeatState

std::map<PLAYLIST::Id, PLAYLIST::RepeatState> PLAYLIST::CPlayListPlayer::m_repeatState
protected
Initial value:
{
{PLAYLIST::TYPE_MUSIC, PLAYLIST::RepeatState::NONE},
{PLAYLIST::TYPE_VIDEO, PLAYLIST::RepeatState::NONE},
{PLAYLIST::TYPE_PICTURE, PLAYLIST::RepeatState::NONE},
}

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