Skip to content
This repository
Browse code

jsonrpc: fix empty properties in Player.GetItem when playing a non-li…

…brary item through Player.Open (fixes #13344)
  • Loading branch information...
commit c6c47ad991e5b788cdfbb7144b276ba631ffd409 1 parent 334d12d
Sascha Montellese authored December 08, 2012
12  xbmc/FileItem.cpp
@@ -1468,7 +1468,8 @@ void CFileItem::UpdateInfo(const CFileItem &item, bool replaceLabels /*=true*/)
1468 1468
 
1469 1469
 void CFileItem::SetFromVideoInfoTag(const CVideoInfoTag &video)
1470 1470
 {
1471  
-  SetLabel(video.m_strTitle);
  1471
+  if (!video.m_strTitle.empty())
  1472
+    SetLabel(video.m_strTitle);
1472 1473
   if (video.m_strFileNameAndPath.IsEmpty())
1473 1474
   {
1474 1475
     m_strPath = video.m_strPath;
@@ -1489,7 +1490,8 @@ void CFileItem::SetFromVideoInfoTag(const CVideoInfoTag &video)
1489 1490
 
1490 1491
 void CFileItem::SetFromAlbum(const CAlbum &album)
1491 1492
 {
1492  
-  SetLabel(album.strAlbum);
  1493
+  if (!album.strAlbum.empty())
  1494
+    SetLabel(album.strAlbum);
1493 1495
   m_bIsFolder = true;
1494 1496
   m_strLabel2 = StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator);
1495 1497
   GetMusicInfoTag()->SetAlbum(album);
@@ -1499,8 +1501,10 @@ void CFileItem::SetFromAlbum(const CAlbum &album)
1499 1501
 
1500 1502
 void CFileItem::SetFromSong(const CSong &song)
1501 1503
 {
1502  
-  SetLabel(song.strTitle);
1503  
-  m_strPath = song.strFileName;
  1504
+  if (!song.strTitle.empty())
  1505
+    SetLabel(song.strTitle);
  1506
+  if (!song.strFileName.empty())
  1507
+    m_strPath = song.strFileName;
1504 1508
   GetMusicInfoTag()->SetSong(song);
1505 1509
   m_lStartOffset = song.iStartOffset;
1506 1510
   m_lStartPartNumber = 1;
5  xbmc/interfaces/json-rpc/AudioLibrary.cpp
@@ -591,6 +591,11 @@ bool CAudioLibrary::FillFileItem(const CStdString &strFilename, CFileItemPtr &it
591 591
       return false;
592 592
   }
593 593
 
  594
+  if (item->GetLabel().empty())
  595
+    item->SetLabel(CUtil::GetTitleFromPath(strFilename, false));
  596
+  if (item->GetLabel())
  597
+    item->SetLabel(URIUtils::GetFileName(strFilename));
  598
+
594 599
   return true;
595 600
 }
596 601
 
17  xbmc/interfaces/json-rpc/PlayerOperations.cpp
@@ -140,17 +140,21 @@ JSONRPC_STATUS CPlayerOperations::GetItem(const CStdString &method, ITransportLa
140 140
       if (player == Video)
141 141
       {
142 142
         bool additionalInfo = false;
  143
+        bool streamdetails = false;
143 144
         for (CVariant::const_iterator_array itr = parameterObject["properties"].begin_array(); itr != parameterObject["properties"].end_array(); itr++)
144 145
         {
145 146
           CStdString fieldValue = itr->asString();
146 147
           if (fieldValue == "cast" || fieldValue == "set" || fieldValue == "setid" || fieldValue == "showlink" || fieldValue == "resume")
147 148
             additionalInfo = true;
  149
+          else if (fieldValue == "streamdetails" && !fileItem->GetVideoInfoTag()->m_streamDetails.HasItems())
  150
+            streamdetails = true;
148 151
         }
149 152
 
150  
-        if (additionalInfo)
  153
+        CVideoDatabase videodatabase;
  154
+        if ((additionalInfo || streamdetails) &&
  155
+            videodatabase.Open())
151 156
         {
152  
-          CVideoDatabase videodatabase;
153  
-          if (videodatabase.Open())
  157
+          if (additionalInfo)
154 158
           {
155 159
             switch (fileItem->GetVideoContentType())
156 160
             {
@@ -171,9 +175,12 @@ JSONRPC_STATUS CPlayerOperations::GetItem(const CStdString &method, ITransportLa
171 175
               default:
172 176
                 break;
173 177
             }
174  
-
175  
-            videodatabase.Close();
176 178
           }
  179
+
  180
+          if (streamdetails)
  181
+            videodatabase.GetStreamDetails(*(fileItem->GetVideoInfoTag()));
  182
+
  183
+          videodatabase.Close();
177 184
         }
178 185
       }
179 186
       else if (player == Audio)
4  xbmc/interfaces/json-rpc/VideoLibrary.cpp
@@ -731,6 +731,10 @@ bool CVideoLibrary::FillFileItem(const CStdString &strFilename, CFileItemPtr &it
731 731
     return false;
732 732
 
733 733
   item->SetFromVideoInfoTag(details);
  734
+  if (item->GetLabel().empty())
  735
+    item->SetLabel(CUtil::GetTitleFromPath(strFilename, false));
  736
+  if (item->GetLabel())
  737
+    item->SetLabel(URIUtils::GetFileName(strFilename));
734 738
   return true;
735 739
 }
736 740
 

0 notes on commit c6c47ad

Please sign in to comment.
Something went wrong with that request. Please try again.