Skip to content
Browse files

[imageloader] adds ability to cache embedded music art

  • Loading branch information...
1 parent 06e1d96 commit fd9df6a586ab79b14f733ac66b25a6bb65f804e2 Jonathan Marshall committed
Showing with 34 additions and 2 deletions.
  1. +16 −2 xbmc/TextureCacheJob.cpp
  2. +11 −0 xbmc/ThumbLoader.cpp
  3. +7 −0 xbmc/ThumbLoader.h
View
18 xbmc/TextureCacheJob.cpp
@@ -33,6 +33,8 @@
#include "utils/StringUtils.h"
#include "URL.h"
#include "FileItem.h"
+#include "ThumbLoader.h"
+#include "music/tags/MusicInfoTag.h"
CTextureCacheJob::CTextureCacheJob(const CStdString &url, const CStdString &oldHash)
{
@@ -78,7 +80,7 @@ bool CTextureCacheJob::CacheTexture(CBaseTexture **out_texture)
unsigned int width, height;
CStdString image = DecodeImageURL(m_url, width, height, additional_info);
- m_details.updateable = UpdateableURL(image);
+ m_details.updateable = additional_info != "music" && UpdateableURL(image);
// generate the hash
m_details.hash = GetImageHash(image);
@@ -130,7 +132,12 @@ CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int
CURL thumbURL(url);
if (!thumbURL.GetUserName().IsEmpty())
- return ""; // we don't re-cache special images (eg picturefolder/video embedded thumbs)
+ {
+ if (thumbURL.GetUserName() == "music")
+ additional_info = "music";
+ else
+ return ""; // we don't re-cache special images (eg picturefolder/video embedded thumbs)
+ }
image = thumbURL.GetHostName();
CURL::Decode(image);
@@ -169,6 +176,13 @@ CStdString CTextureCacheJob::DecodeImageURL(const CStdString &url, unsigned int
CBaseTexture *CTextureCacheJob::LoadImage(const CStdString &image, unsigned int width, unsigned int height, const std::string &additional_info)
{
+ if (additional_info == "music")
+ { // special case for embedded music images
+ MUSIC_INFO::EmbeddedArt art;
+ if (CMusicThumbLoader::GetEmbeddedThumb(image, art))
+ return CBaseTexture::LoadFromFileInMemory(&art.data[0], art.size, art.mime, width, height);
+ }
+
// Validate file URL to see if it is an image
CFileItem file(image, false);
if (!(file.IsPicture() && !(file.IsZIP() || file.IsRAR() || file.IsCBR() || file.IsCBZ() ))
View
11 xbmc/ThumbLoader.cpp
@@ -38,6 +38,7 @@
#include "cores/dvdplayer/DVDFileInfo.h"
#include "video/VideoInfoScanner.h"
#include "music/tags/MusicInfoTag.h"
+#include "music/tags/MusicInfoTagLoaderFactory.h"
#include "music/infoscanner/MusicInfoScanner.h"
#include "music/Artist.h"
@@ -598,3 +599,13 @@ bool CMusicThumbLoader::FillLibraryArt(CFileItem &item)
}
return !item.GetArt().empty();
}
+
+bool CMusicThumbLoader::GetEmbeddedThumb(const std::string &path, EmbeddedArt &art)
+{
+ auto_ptr<IMusicInfoTagLoader> pLoader (CMusicInfoTagLoaderFactory::CreateLoader(path));
+ CMusicInfoTag tag;
+ if (NULL != pLoader.get())
+ pLoader->Load(path, tag, &art);
+
+ return !art.empty();
+}
View
7 xbmc/ThumbLoader.h
@@ -156,6 +156,11 @@ class CProgramThumbLoader : public CThumbLoader
static CStdString GetLocalThumb(const CFileItem &item);
};
+namespace MUSIC_INFO
+{
+ class EmbeddedArt;
+};
+
class CMusicThumbLoader : public CThumbLoader
{
public:
@@ -169,6 +174,8 @@ class CMusicThumbLoader : public CThumbLoader
*/
bool FillLibraryArt(CFileItem &item);
+ static bool GetEmbeddedThumb(const std::string &path, MUSIC_INFO::EmbeddedArt &art);
+
protected:
virtual void OnLoaderStart();
virtual void OnLoaderFinish();

0 comments on commit fd9df6a

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