blob: 8aa92be697de2634d52ba78ea9f475aed00673fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "PlayListTypes.h"
#include <memory>
#include <string>
#include <vector>
class CFileItem;
class CFileItemList;
namespace PLAYLIST
{
class CPlayList
{
public:
explicit CPlayList(PLAYLIST::Id id = PLAYLIST::TYPE_NONE);
virtual ~CPlayList(void) = default;
virtual bool Load(const std::string& strFileName);
virtual bool LoadData(std::istream &stream);
virtual bool LoadData(const std::string& strData);
virtual void Save(const std::string& strFileName) const {};
void Add(const CPlayList& playlist);
void Add(const std::shared_ptr<CFileItem>& pItem);
void Add(const CFileItemList& items);
// for Party Mode
void Insert(const CPlayList& playlist, int iPosition = -1);
void Insert(const CFileItemList& items, int iPosition = -1);
void Insert(const std::shared_ptr<CFileItem>& item, int iPosition = -1);
int FindOrder(int iOrder) const;
const std::string& GetName() const;
void Remove(const std::string& strFileName);
void Remove(int position);
bool Swap(int position1, int position2);
bool Expand(int position); // expands any playlist at position into this playlist
void Clear();
int size() const;
int RemoveDVDItems();
const std::shared_ptr<CFileItem> operator[](int iItem) const;
std::shared_ptr<CFileItem> operator[](int iItem);
void Shuffle(int iPosition = 0);
void UnShuffle();
bool IsShuffled() const { return m_bShuffled; }
void SetPlayed(bool bPlayed) { m_bWasPlayed = true; }
bool WasPlayed() const { return m_bWasPlayed; }
void SetUnPlayable(int iItem);
int GetPlayable() const { return m_iPlayableItems; }
void UpdateItem(const CFileItem *item);
const std::string& ResolveURL(const std::shared_ptr<CFileItem>& item) const;
protected:
PLAYLIST::Id m_id;
std::string m_strPlayListName;
std::string m_strBasePath;
int m_iPlayableItems;
bool m_bShuffled;
bool m_bWasPlayed;
// CFileItemList m_vecItems;
std::vector<std::shared_ptr<CFileItem>> m_vecItems;
typedef std::vector<std::shared_ptr<CFileItem>>::iterator ivecItems;
private:
void Add(const std::shared_ptr<CFileItem>& item, int iPosition, int iOrderOffset);
void DecrementOrder(int iOrder);
void IncrementOrder(int iPosition, int iOrder);
void AnnounceRemove(int pos);
void AnnounceClear();
void AnnounceAdd(const std::shared_ptr<CFileItem>& item, int pos);
};
typedef std::shared_ptr<CPlayList> CPlayListPtr;
}
|