2019-01-27, 12:53
Hello
I tried to fix some performance issues on large (music) playlists.
Here is my new approach, but still in progress...
As you can see, the playlist creation is not a two stage solution.
First, just load the selected item and play it directly.
Then queue the playlist in the second step. This part has to be transferred in a asynchron thread. This is still pending.
Another pending task is shuffling. The playlist should be shuffled while creation.
I tried to fix some performance issues on large (music) playlists.
Here is my new approach, but still in progress...
cpp:
bool CGUIMediaWindow::OnPlayAndQueueMedia(const CFileItemPtr &item, std:tring player)
{
//play and add current directory to temporary playlist
int iPlaylist = m_guiState->GetPlaylist();
if (iPlaylist != PLAYLIST_NONE)
{
CServiceBroker::GetPlaylistPlayer().ClearPlaylist(iPlaylist);
CServiceBroker::GetPlaylistPlayer().Reset();
int mediaToPlay = 0;
// first try to find mainDVD file (VIDEO_TS.IFO).
// If we find this we should not allow to queue VOB files
std:tring mainDVD;
for (int i = 0; i < m_vecItems->Size(); i++)
{
std:tring path = URIUtils::GetFileName(m_vecItems->Get(i)->GetPath());
if (StringUtils::EqualsNoCase(path, "VIDEO_TS.IFO"))
{
mainDVD = path;
break;
}
}
// Load selected file into playlist
for ( int i = 0; i < m_vecItems->Size(); i++ )
{
CFileItemPtr nItem = m_vecItems->Get(i);
if (nItem->m_bIsFolder)
continue;
if (item->IsSamePath(nItem.get()))
{ // item that was clicked
CServiceBroker::GetPlaylistPlayer().Add(iPlaylist, nItem);
mediaToPlay = CServiceBroker::GetPlaylistPlayer().GetPlaylist(iPlaylist).size() - 1;
}
}
// Save current window and directory to know where the selected item was
if (m_guiState.get())
m_guiState->SetPlaylistDirectory(m_vecItems->GetPath());
// figure out where we start playback
if (CServiceBroker::GetPlaylistPlayer().IsShuffled(iPlaylist))
{
int iIndex = CServiceBroker::GetPlaylistPlayer().GetPlaylist(iPlaylist).FindOrder(mediaToPlay);
CServiceBroker::GetPlaylistPlayer().GetPlaylist(iPlaylist).Swap(0, iIndex);
mediaToPlay = 0;
}
// play
CServiceBroker::GetPlaylistPlayer().SetCurrentPlaylist(iPlaylist);
CServiceBroker::GetPlaylistPlayer().Play(mediaToPlay, player);
// now queue...
//THIS SHOULD RUN IN A ASYNCRON THREAD
for ( int i = 0; i < m_vecItems->Size(); i++ )
{
CFileItemPtr nItem = m_vecItems->Get(i);
if (nItem->m_bIsFolder)
continue;
if (!nItem->IsZIP() && !nItem->IsRAR() && (!nItem->IsDVDFile() || (URIUtils::GetFileName(nItem->GetPath()) == mainDVD)))
if (i <= 10) //For debug reasons, playlist is limited to 10 items
if (!item->IsSamePath(nItem.get()))
{ // item that was clicked
CServiceBroker::GetPlaylistPlayer().Insert(iPlaylist, nItem, i);
}
}
}
return true;
}
As you can see, the playlist creation is not a two stage solution.
First, just load the selected item and play it directly.
Then queue the playlist in the second step. This part has to be transferred in a asynchron thread. This is still pending.
Another pending task is shuffling. The playlist should be shuffled while creation.