[videodb] Remove nested transaction when saving state after stopping PVR playback
[xbmc.git] / xbmc / filesystem / PlaylistDirectory.cpp
blob8d77552ca4d97fd9bec97029668394da298e40c0
1 /*
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.
7 */
9 #include "PlaylistDirectory.h"
11 #include "FileItem.h"
12 #include "FileItemList.h"
13 #include "PlayListPlayer.h"
14 #include "ServiceBroker.h"
15 #include "URL.h"
16 #include "playlists/PlayList.h"
18 using namespace KODI;
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)
34 return false;
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!
45 items.Add(item);
48 return true;