2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "PlaylistDirectory.h"
12 #include "FileItemList.h"
13 #include "PlayListPlayer.h"
14 #include "ServiceBroker.h"
16 #include "playlists/PlayList.h"
19 using namespace XFILE
;
21 CPlaylistDirectory::CPlaylistDirectory() = default;
23 CPlaylistDirectory::~CPlaylistDirectory() = default;
25 bool CPlaylistDirectory::GetDirectory(const CURL
& url
, CFileItemList
&items
)
27 PLAYLIST::Id playlistId
= PLAYLIST::Id::TYPE_NONE
;
28 if (url
.IsProtocol("playlistmusic"))
29 playlistId
= PLAYLIST::Id::TYPE_MUSIC
;
30 else if (url
.IsProtocol("playlistvideo"))
31 playlistId
= PLAYLIST::Id::TYPE_VIDEO
;
33 if (playlistId
== PLAYLIST::Id::TYPE_NONE
)
36 const PLAYLIST::CPlayList
& playlist
= CServiceBroker::GetPlaylistPlayer().GetPlaylist(playlistId
);
37 items
.Reserve(playlist
.size());
39 for (int i
= 0; i
< playlist
.size(); ++i
)
41 CFileItemPtr item
= playlist
[i
];
42 item
->SetProperty("playlistposition", i
);
43 item
->SetProperty("playlisttype", static_cast<int>(playlistId
));
44 //item->m_iprogramCount = i; // the programCount is set as items are added!