Skip to content

Commit

Permalink
jsonrpc: fix empty properties in Player.GetItem when playing a non-li…
Browse files Browse the repository at this point in the history
…brary item through Player.Open (fixes #13344)
  • Loading branch information
Montellese committed Dec 8, 2012
1 parent 334d12d commit c6c47ad
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
12 changes: 8 additions & 4 deletions xbmc/FileItem.cpp
Expand Up @@ -1468,7 +1468,8 @@ void CFileItem::UpdateInfo(const CFileItem &item, bool replaceLabels /*=true*/)

void CFileItem::SetFromVideoInfoTag(const CVideoInfoTag &video)
{
SetLabel(video.m_strTitle);
if (!video.m_strTitle.empty())
SetLabel(video.m_strTitle);
if (video.m_strFileNameAndPath.IsEmpty())
{
m_strPath = video.m_strPath;
Expand All @@ -1489,7 +1490,8 @@ void CFileItem::SetFromVideoInfoTag(const CVideoInfoTag &video)

void CFileItem::SetFromAlbum(const CAlbum &album)
{
SetLabel(album.strAlbum);
if (!album.strAlbum.empty())
SetLabel(album.strAlbum);
m_bIsFolder = true;
m_strLabel2 = StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator);
GetMusicInfoTag()->SetAlbum(album);
Expand All @@ -1499,8 +1501,10 @@ void CFileItem::SetFromAlbum(const CAlbum &album)

void CFileItem::SetFromSong(const CSong &song)
{
SetLabel(song.strTitle);
m_strPath = song.strFileName;
if (!song.strTitle.empty())
SetLabel(song.strTitle);
if (!song.strFileName.empty())
m_strPath = song.strFileName;
GetMusicInfoTag()->SetSong(song);
m_lStartOffset = song.iStartOffset;
m_lStartPartNumber = 1;
Expand Down
5 changes: 5 additions & 0 deletions xbmc/interfaces/json-rpc/AudioLibrary.cpp
Expand Up @@ -591,6 +591,11 @@ bool CAudioLibrary::FillFileItem(const CStdString &strFilename, CFileItemPtr &it
return false;
}

if (item->GetLabel().empty())
item->SetLabel(CUtil::GetTitleFromPath(strFilename, false));
if (item->GetLabel())
item->SetLabel(URIUtils::GetFileName(strFilename));

return true;
}

Expand Down
17 changes: 12 additions & 5 deletions xbmc/interfaces/json-rpc/PlayerOperations.cpp
Expand Up @@ -140,17 +140,21 @@ JSONRPC_STATUS CPlayerOperations::GetItem(const CStdString &method, ITransportLa
if (player == Video)
{
bool additionalInfo = false;
bool streamdetails = false;
for (CVariant::const_iterator_array itr = parameterObject["properties"].begin_array(); itr != parameterObject["properties"].end_array(); itr++)
{
CStdString fieldValue = itr->asString();
if (fieldValue == "cast" || fieldValue == "set" || fieldValue == "setid" || fieldValue == "showlink" || fieldValue == "resume")
additionalInfo = true;
else if (fieldValue == "streamdetails" && !fileItem->GetVideoInfoTag()->m_streamDetails.HasItems())
streamdetails = true;
}

if (additionalInfo)
CVideoDatabase videodatabase;
if ((additionalInfo || streamdetails) &&
videodatabase.Open())
{
CVideoDatabase videodatabase;
if (videodatabase.Open())
if (additionalInfo)
{
switch (fileItem->GetVideoContentType())
{
Expand All @@ -171,9 +175,12 @@ JSONRPC_STATUS CPlayerOperations::GetItem(const CStdString &method, ITransportLa
default:
break;
}

videodatabase.Close();
}

if (streamdetails)
videodatabase.GetStreamDetails(*(fileItem->GetVideoInfoTag()));

videodatabase.Close();
}
}
else if (player == Audio)
Expand Down
4 changes: 4 additions & 0 deletions xbmc/interfaces/json-rpc/VideoLibrary.cpp
Expand Up @@ -731,6 +731,10 @@ bool CVideoLibrary::FillFileItem(const CStdString &strFilename, CFileItemPtr &it
return false;

item->SetFromVideoInfoTag(details);
if (item->GetLabel().empty())
item->SetLabel(CUtil::GetTitleFromPath(strFilename, false));
if (item->GetLabel())
item->SetLabel(URIUtils::GetFileName(strFilename));
return true;
}

Expand Down

0 comments on commit c6c47ad

Please sign in to comment.