kodi
PartyModeManager.h
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
11 #include <memory>
12 #include <string>
13 #include <utility>
14 #include <vector>
15 
16 class CFileItem; typedef std::shared_ptr<CFileItem> CFileItemPtr;
17 class CFileItemList;
18 namespace PLAYLIST
19 {
20 using Id = int;
21 class CPlayList;
22 }
23 
24 typedef enum
25 {
26  PARTYMODECONTEXT_UNKNOWN,
27  PARTYMODECONTEXT_MUSIC,
28  PARTYMODECONTEXT_VIDEO
29 } PartyModeContext;
30 
31 class CPartyModeManager final
32 {
33 public:
34  CPartyModeManager(void);
35 
36  bool Enable(PartyModeContext context=PARTYMODECONTEXT_MUSIC, const std::string& strXspPath = "");
37  void Disable();
38  void Play(int iPos);
39  void OnSongChange(bool bUpdatePlayed = false);
40  void AddUserSongs(PLAYLIST::CPlayList& tempList, bool bPlay = false);
41  void AddUserSongs(CFileItemList& tempList, bool bPlay = false);
42  bool IsEnabled(PartyModeContext context=PARTYMODECONTEXT_UNKNOWN) const;
43  int GetSongsPlayed();
44  int GetMatchingSongs();
45  int GetMatchingSongsPicked();
46  int GetMatchingSongsLeft();
47  int GetRelaxedSongs();
48  int GetRandomSongs();
49  PartyModeContext GetType() const;
50 
51 private:
52  void Process();
53  bool AddRandomSongs();
54  void Add(CFileItemPtr &pItem);
55  bool ReapSongs();
56  bool MovePlaying();
57  void SendUpdateMessage();
58  void OnError(int iError, const std::string& strLogMessage);
59  void ClearState();
60  void UpdateStats();
61  void Announce();
62  PLAYLIST::Id GetPlaylistId() const;
63 
64  // state
65  bool m_bEnabled;
66  bool m_bIsVideo;
67  int m_iLastUserSong;
68  std::string m_type;
69 
70  // statistics
71  int m_iSongsPlayed;
72  int m_iMatchingSongs;
73  int m_iMatchingSongsPicked;
74  int m_iMatchingSongsLeft;
75  int m_iRelaxedSongs;
76  int m_iRandomSongs;
77 
78  // history
79  std::vector<std::pair<int, int>> m_songIDCache;
80 };
81 
82 extern CPartyModeManager g_partyModeManager;
Definition: PartyModeManager.h:31
Definition: Application.h:62
std::shared_ptr< CFileItem > CFileItemPtr
A shared pointer to CFileItem.
Definition: FileItem.h:669
Represents a list of files.
Definition: FileItem.h:702
Definition: PlayList.h:23
Represents a file on a share.
Definition: FileItem.h:102