本文整理汇总了C++中CFileItemPtr::GetVideoContentType方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItemPtr::GetVideoContentType方法的具体用法?C++ CFileItemPtr::GetVideoContentType怎么用?C++ CFileItemPtr::GetVideoContentType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileItemPtr
的用法示例。
在下文中一共展示了CFileItemPtr::GetVideoContentType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Announce
void CAnnouncementManager::Announce(EAnnouncementFlag flag, const char *sender, const char *message, CFileItemPtr item, CVariant &data)
{
// Extract db id of item
CVariant object = data.isNull() || data.isObject() ? data : CVariant::VariantTypeObject;
CStdString type;
int id = 0;
if (item->HasVideoInfoTag())
{
CVideoDatabase::VideoContentTypeToString((VIDEODB_CONTENT_TYPE)item->GetVideoContentType(), type);
id = item->GetVideoInfoTag()->m_iDbId;
}
else if (item->HasMusicInfoTag())
{
if (item->IsAlbum())
type = "album";
else
type = "song";
id = item->GetMusicInfoTag()->GetDatabaseId();
}
else
type = "unknown";
object["type"] = type;
if (id > 0)
object["id"] = id;
Announce(flag, sender, message, object);
}
示例2: Announce
void CAnnouncementManager::Announce(EAnnouncementFlag flag, const char *sender, const char *message, CFileItemPtr item, CVariant &data)
{
// Extract db id of item
CVariant object = data.isNull() || data.isObject() ? data : CVariant::VariantTypeObject;
CStdString type;
int id = 0;
if (item->HasVideoInfoTag())
{
CVideoDatabase::VideoContentTypeToString(item->GetVideoContentType(), type);
id = item->GetVideoInfoTag()->m_iDbId;
}
else if (item->HasMusicInfoTag())
{
type = "music";
id = item->GetMusicInfoTag()->GetDatabaseId();
}
if (id > 0)
{
type += "id";
object[type] = id;
}
Announce(flag, sender, message, object);
}
示例3: GetItem
JSONRPC_STATUS CPlayerOperations::GetItem(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
PlayerType player = GetPlayer(parameterObject["playerid"]);
CFileItemPtr fileItem;
switch (player)
{
case Video:
case Audio:
{
fileItem = CFileItemPtr(new CFileItem(g_application.CurrentFileItem()));
if (fileItem->GetLabel().empty())
{
if (IsPVRChannel())
{
CPVRChannelPtr currentChannel;
if (g_PVRManager.GetCurrentChannel(currentChannel) && currentChannel.get() != NULL)
fileItem = CFileItemPtr(new CFileItem(*currentChannel.get()));
}
else if (player == Video)
{
if (!CVideoLibrary::FillFileItem(g_application.CurrentFile(), fileItem, parameterObject))
{
const CVideoInfoTag *currentVideoTag = g_infoManager.GetCurrentMovieTag();
if (currentVideoTag != NULL)
fileItem = CFileItemPtr(new CFileItem(*currentVideoTag));
fileItem->SetPath(g_application.CurrentFileItem().GetPath());
}
}
else
{
if (!CAudioLibrary::FillFileItem(g_application.CurrentFile(), fileItem, parameterObject))
{
const MUSIC_INFO::CMusicInfoTag *currentMusicTag = g_infoManager.GetCurrentSongTag();
if (currentMusicTag != NULL)
fileItem = CFileItemPtr(new CFileItem(*currentMusicTag));
fileItem->SetPath(g_application.CurrentFileItem().GetPath());
}
}
}
if (IsPVRChannel())
break;
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" ||
(fieldValue == "streamdetails" && !fileItem->GetVideoInfoTag()->m_streamDetails.HasItems()))
additionalInfo = true;
}
CVideoDatabase videodatabase;
if ((additionalInfo) &&
videodatabase.Open())
{
if (additionalInfo)
{
switch (fileItem->GetVideoContentType())
{
case VIDEODB_CONTENT_MOVIES:
videodatabase.GetMovieInfo("", *(fileItem->GetVideoInfoTag()), fileItem->GetVideoInfoTag()->m_iDbId);
break;
case VIDEODB_CONTENT_MUSICVIDEOS:
videodatabase.GetMusicVideoInfo("", *(fileItem->GetVideoInfoTag()), fileItem->GetVideoInfoTag()->m_iDbId);
break;
case VIDEODB_CONTENT_EPISODES:
videodatabase.GetEpisodeInfo("", *(fileItem->GetVideoInfoTag()), fileItem->GetVideoInfoTag()->m_iDbId);
break;
case VIDEODB_CONTENT_TVSHOWS:
case VIDEODB_CONTENT_MOVIE_SETS:
default:
break;
}
}
videodatabase.Close();
}
}
else if (player == Audio)
{
if (fileItem->IsMusicDb())
{
CMusicDatabase musicdb;
CFileItemList items;
items.Add(fileItem);
CAudioLibrary::GetAdditionalSongDetails(parameterObject, items, musicdb);
}
}
break;
}
case Picture:
//.........这里部分代码省略.........
示例4: GetField
//.........这里部分代码省略.........
}
}
if (item->HasProperty("artist_" + field + "_array"))
{
result[field] = item->GetProperty("artist_" + field + "_array");
return true;
}
if (item->HasProperty("artist_" + field))
{
result[field] = item->GetProperty("artist_" + field);
return true;
}
if (field == "art")
{
if (thumbLoader != NULL && item->GetArt().size() <= 0 && !fetchedArt &&
((item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iDbId > -1) || (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDatabaseId() > -1)))
{
thumbLoader->FillLibraryArt(*item);
fetchedArt = true;
}
CGUIListItem::ArtMap artMap = item->GetArt();
CVariant artObj(CVariant::VariantTypeObject);
for (CGUIListItem::ArtMap::const_iterator artIt = artMap.begin(); artIt != artMap.end(); ++artIt)
{
if (!artIt->second.empty())
artObj[artIt->first] = CTextureCache::GetWrappedImageURL(artIt->second);
}
result["art"] = artObj;
return true;
}
if (field == "thumbnail")
{
if (thumbLoader != NULL && !item->HasArt("thumb") && !fetchedArt &&
((item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iDbId > -1) || (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDatabaseId() > -1)))
{
thumbLoader->FillLibraryArt(*item);
fetchedArt = true;
}
else if (item->HasPictureInfoTag() && !item->HasArt("thumb"))
item->SetArt("thumb", CTextureCache::GetWrappedThumbURL(item->GetPath()));
if (item->HasArt("thumb"))
result["thumbnail"] = CTextureCache::GetWrappedImageURL(item->GetArt("thumb"));
else
result["thumbnail"] = "";
return true;
}
if (field == "fanart")
{
if (thumbLoader != NULL && !item->HasArt("fanart") && !fetchedArt &&
((item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iDbId > -1) || (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDatabaseId() > -1)))
{
thumbLoader->FillLibraryArt(*item);
fetchedArt = true;
}
if (item->HasArt("fanart"))
result["fanart"] = CTextureCache::GetWrappedImageURL(item->GetArt("fanart"));
else
result["fanart"] = "";
return true;
}
if (item->HasVideoInfoTag() && item->GetVideoContentType() == VIDEODB_CONTENT_TVSHOWS)
{
if (item->GetVideoInfoTag()->m_iSeason < 0 && field == "season")
{
result[field] = (int)item->GetProperty("totalseasons").asInteger();
return true;
}
if (field == "watchedepisodes")
{
result[field] = (int)item->GetProperty("watchedepisodes").asInteger();
return true;
}
}
if (field == "lastmodified" && item->m_dateTime.IsValid())
{
result[field] = item->m_dateTime.GetAsLocalizedDateTime();
return true;
}
if (item->HasProperty(field))
{
result[field] = item->GetProperty(field);
return true;
}
}
return false;
}
示例5: Announce
void CAnnouncementManager::Announce(AnnouncementFlag flag, const char *sender, const char *message, CFileItemPtr item, CVariant &data)
{
if (!item.get())
{
Announce(flag, sender, message, data);
return;
}
// Extract db id of item
CVariant object = data.isNull() || data.isObject() ? data : CVariant::VariantTypeObject;
CStdString type;
int id = 0;
if(item->HasPVRChannelInfoTag())
{
const PVR::CPVRChannel *channel = item->GetPVRChannelInfoTag();
id = channel->ChannelID();
type = "channel";
object["item"]["title"] = channel->ChannelName();
object["item"]["channeltype"] = channel->IsRadio() ? "radio" : "tv";
if (data.isMember("player") && data["player"].isMember("playerid"))
object["player"]["playerid"] = channel->IsRadio() ? PLAYLIST_MUSIC : PLAYLIST_VIDEO;
}
else if (item->HasVideoInfoTag())
{
id = item->GetVideoInfoTag()->m_iDbId;
// TODO: Can be removed once this is properly handled when starting playback of a file
if (id <= 0 && !item->GetPath().empty() &&
(!item->HasProperty(LOOKUP_PROPERTY) || item->GetProperty(LOOKUP_PROPERTY).asBoolean()))
{
CVideoDatabase videodatabase;
if (videodatabase.Open())
{
if (videodatabase.LoadVideoInfo(item->GetPath(), *item->GetVideoInfoTag()))
id = item->GetVideoInfoTag()->m_iDbId;
videodatabase.Close();
}
}
if (!item->GetVideoInfoTag()->m_type.empty())
type = item->GetVideoInfoTag()->m_type;
else
CVideoDatabase::VideoContentTypeToString((VIDEODB_CONTENT_TYPE)item->GetVideoContentType(), type);
if (id <= 0)
{
// TODO: Can be removed once this is properly handled when starting playback of a file
item->SetProperty(LOOKUP_PROPERTY, false);
object["item"]["title"] = item->GetVideoInfoTag()->m_strTitle;
switch (item->GetVideoContentType())
{
case VIDEODB_CONTENT_MOVIES:
if (item->GetVideoInfoTag()->m_iYear > 0)
object["item"]["year"] = item->GetVideoInfoTag()->m_iYear;
break;
case VIDEODB_CONTENT_EPISODES:
if (item->GetVideoInfoTag()->m_iEpisode >= 0)
object["item"]["episode"] = item->GetVideoInfoTag()->m_iEpisode;
if (item->GetVideoInfoTag()->m_iSeason >= 0)
object["item"]["season"] = item->GetVideoInfoTag()->m_iSeason;
if (!item->GetVideoInfoTag()->m_strShowTitle.empty())
object["item"]["showtitle"] = item->GetVideoInfoTag()->m_strShowTitle;
break;
case VIDEODB_CONTENT_MUSICVIDEOS:
if (!item->GetVideoInfoTag()->m_strAlbum.empty())
object["item"]["album"] = item->GetVideoInfoTag()->m_strAlbum;
if (!item->GetVideoInfoTag()->m_artist.empty())
object["item"]["artist"] = StringUtils::Join(item->GetVideoInfoTag()->m_artist, " / ");
break;
}
}
}
else if (item->HasMusicInfoTag())
{
id = item->GetMusicInfoTag()->GetDatabaseId();
type = "song";
// TODO: Can be removed once this is properly handled when starting playback of a file
if (id <= 0 && !item->GetPath().empty() &&
(!item->HasProperty(LOOKUP_PROPERTY) || item->GetProperty(LOOKUP_PROPERTY).asBoolean()))
{
CMusicDatabase musicdatabase;
if (musicdatabase.Open())
{
CSong song;
if (musicdatabase.GetSongByFileName(item->GetPath(), song, item->m_lStartOffset))
{
item->GetMusicInfoTag()->SetSong(song);
id = item->GetMusicInfoTag()->GetDatabaseId();
}
musicdatabase.Close();
}
}
//.........这里部分代码省略.........
示例6: HandleFileItem
void CFileItemHandler::HandleFileItem(const char *ID, bool allowFile, const char *resultname, CFileItemPtr item, const CVariant ¶meterObject, const CVariant &validFields, CVariant &result, bool append /* = true */)
{
CVariant object;
bool hasFileField = false;
bool hasThumbnailField = false;
if (item.get())
{
for (unsigned int i = 0; i < validFields.size(); i++)
{
CStdString field = validFields[i].asString();
if (field == "file")
hasFileField = true;
if (field == "thumbnail")
hasThumbnailField = true;
}
if (allowFile && hasFileField)
{
if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->GetPath().IsEmpty())
object["file"] = item->GetVideoInfoTag()->GetPath().c_str();
if (item->HasMusicInfoTag() && !item->GetMusicInfoTag()->GetURL().IsEmpty())
object["file"] = item->GetMusicInfoTag()->GetURL().c_str();
if (!object.isMember("file"))
object["file"] = item->GetPath().c_str();
}
if (ID)
{
if(stricmp(ID, "spotify_albumid") == 0)
{
CStdString spotify_albumid = item->GetPath();
object[ID] = spotify_albumid.c_str();
}
if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDatabaseId() > 0)
object[ID] = (int)item->GetMusicInfoTag()->GetDatabaseId();
else if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iDbId > 0)
object[ID] = item->GetVideoInfoTag()->m_iDbId;
if (stricmp(ID, "id") == 0)
{
if (item->HasMusicInfoTag())
{
if (item->m_bIsFolder && item->IsAlbum())
object["type"] = "album";
else
object["type"] = "song";
}
else if (item->HasVideoInfoTag())
{
switch (item->GetVideoContentType())
{
case VIDEODB_CONTENT_EPISODES:
object["type"] = "episode";
break;
case VIDEODB_CONTENT_MUSICVIDEOS:
object["type"] = "musicvideo";
break;
case VIDEODB_CONTENT_MOVIES:
object["type"] = "movie";
break;
case VIDEODB_CONTENT_TVSHOWS:
object["type"] = "tvshow";
break;
default:
break;
}
}
else if (item->HasPictureInfoTag())
object["type"] = "picture";
if (!object.isMember("type"))
object["type"] = "unknown";
}
}
if (hasThumbnailField)
{
if (item->HasThumbnail())
object["thumbnail"] = item->GetThumbnailImage().c_str();
else if (item->HasVideoInfoTag())
{
CStdString strPath, strFileName;
URIUtils::Split(item->GetCachedVideoThumb(), strPath, strFileName);
CStdString cachedThumb = strPath + "auto-" + strFileName;
if (CFile::Exists(cachedThumb))
object["thumbnail"] = cachedThumb;
}
else if (item->HasPictureInfoTag())
{
CStdString thumb = CTextureCache::Get().CheckAndCacheImage(CTextureCache::GetWrappedThumbURL(item->GetPath()));
if (!thumb.empty())
object["thumbnail"] = thumb;
//.........这里部分代码省略.........
示例7: FillDetails
//.........这里部分代码省略.........
}
}
if (item->HasProperty("artist_" + field + "_array"))
{
result[field] = item->GetProperty("artist_" + field + "_array");
continue;
}
if (item->HasProperty("artist_" + field))
{
result[field] = item->GetProperty("artist_" + field);
continue;
}
if (field == "thumbnail")
{
if (item->HasVideoInfoTag())
{
if (!item->HasThumbnail() && !fetchedArt && item->GetVideoInfoTag()->m_iDbId > -1)
{
CVideoThumbLoader loader;
loader.FillLibraryArt(item.get());
fetchedArt = true;
}
}
else if (item->HasPictureInfoTag())
{
if (!item->HasThumbnail())
item->SetThumbnailImage(CTextureCache::GetWrappedThumbURL(item->GetPath()));
}
else if (item->HasMusicInfoTag())
{
if (!item->HasThumbnail() && !fetchedArt && item->GetMusicInfoTag()->GetDatabaseId() > -1)
{
CMusicThumbLoader loader;
loader.FillLibraryArt(*item);
fetchedArt = true;
}
}
if (item->HasThumbnail())
result["thumbnail"] = CTextureCache::GetWrappedImageURL(item->GetThumbnailImage());
if (!result.isMember("thumbnail"))
result["thumbnail"] = "";
continue;
}
if (field == "fanart")
{
if (item->HasVideoInfoTag())
{
if (!item->HasProperty("fanart_image") && !fetchedArt && item->GetVideoInfoTag()->m_iDbId > -1)
{
CVideoThumbLoader loader;
loader.FillLibraryArt(item.get());
fetchedArt = true;
}
if (item->HasProperty("fanart_image"))
result["fanart"] = CTextureCache::GetWrappedImageURL(item->GetProperty("fanart_image").asString());
}
else if (item->HasMusicInfoTag())
{
if (!item->HasProperty("fanart_image") && !fetchedArt && item->GetMusicInfoTag()->GetDatabaseId() > -1)
{
CMusicThumbLoader loader;
loader.FillLibraryArt(*item);
fetchedArt = true;
}
if (item->HasProperty("fanart_image"))
result["fanart"] = CTextureCache::GetWrappedImageURL(item->GetProperty("fanart_image").asString());
}
if (!result.isMember("fanart"))
result["fanart"] = "";
continue;
}
if (item->HasVideoInfoTag() && item->GetVideoContentType() == VIDEODB_CONTENT_TVSHOWS)
{
if (item->GetVideoInfoTag()->m_iSeason < 0 && field == "season")
{
result[field] = (int)item->GetProperty("totalseasons").asInteger();
continue;
}
if (field == "watchedepisodes")
{
result[field] = (int)item->GetProperty("watchedepisodes").asInteger();
continue;
}
}
if (field == "lastmodified" && item->m_dateTime.IsValid())
{
result[field] = item->m_dateTime.GetAsLocalizedDateTime();
continue;
}
}
if (serialization.isMember(field) && (!result.isMember(field) || result[field].empty()))
result[field] = serialization[field];
}
}
示例8: HandleFileItem
void CFileItemHandler::HandleFileItem(const char *ID, bool allowFile, const char *resultname, CFileItemPtr item, const CVariant ¶meterObject, const CVariant &validFields, CVariant &result, bool append /* = true */)
{
CVariant object;
bool hasFileField = false;
if (item.get())
{
for (unsigned int i = 0; i < validFields.size(); i++)
{
CStdString field = validFields[i].asString();
if (field == "file")
hasFileField = true;
}
if (allowFile && hasFileField)
{
if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->GetPath().IsEmpty())
object["file"] = item->GetVideoInfoTag()->GetPath().c_str();
if (item->HasMusicInfoTag() && !item->GetMusicInfoTag()->GetURL().IsEmpty())
object["file"] = item->GetMusicInfoTag()->GetURL().c_str();
if (!object.isMember("file"))
object["file"] = item->GetPath().c_str();
}
if (ID)
{
if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDatabaseId() > 0)
object[ID] = (int)item->GetMusicInfoTag()->GetDatabaseId();
else if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iDbId > 0)
object[ID] = item->GetVideoInfoTag()->m_iDbId;
if (stricmp(ID, "id") == 0)
{
if (item->HasMusicInfoTag())
{
if (item->m_bIsFolder && item->IsAlbum())
object["type"] = "album";
else
object["type"] = "song";
}
else if (item->HasVideoInfoTag())
{
switch (item->GetVideoContentType())
{
case VIDEODB_CONTENT_EPISODES:
object["type"] = "episode";
break;
case VIDEODB_CONTENT_MUSICVIDEOS:
object["type"] = "musicvideo";
break;
case VIDEODB_CONTENT_MOVIES:
object["type"] = "movie";
break;
case VIDEODB_CONTENT_TVSHOWS:
object["type"] = "tvshow";
break;
default:
break;
}
}
else if (item->HasPictureInfoTag())
object["type"] = "picture";
if (!object.isMember("type"))
object["type"] = "unknown";
}
}
FillDetails(item.get(), item, validFields, object);
if (item->HasVideoInfoTag())
FillDetails(item->GetVideoInfoTag(), item, validFields, object);
if (item->HasMusicInfoTag())
FillDetails(item->GetMusicInfoTag(), item, validFields, object);
if (item->HasPictureInfoTag())
FillDetails(item->GetPictureInfoTag(), item, validFields, object);
object["label"] = item->GetLabel().c_str();
}
else
object = CVariant(CVariant::VariantTypeNull);
if (resultname)
{
if (append)
result[resultname].append(object);
else
result[resultname] = object;
}
}
示例9: FillDetails
void CFileItemHandler::FillDetails(ISerializable* info, CFileItemPtr item, const CVariant& fields, CVariant &result)
{
if (info == NULL || fields.size() == 0)
return;
CVariant serialization;
info->Serialize(serialization);
for (unsigned int i = 0; i < fields.size(); i++)
{
CStdString field = fields[i].asString();
if (item)
{
if (item->IsAlbum() && field.Equals("albumlabel"))
field = "label";
if (item->IsAlbum())
{
if (field == "label")
{
result["albumlabel"] = item->GetProperty("album_label");
continue;
}
/* This would break backwards compatibility to JSON-RPC API v4
if (item->HasProperty("album_" + field + "_array"))
{
result[field] = item->GetProperty("album_" + field + "_array");
continue;
}*/
if (item->HasProperty("album_" + field))
{
result[field] = item->GetProperty("album_" + field);
continue;
}
}
/* This would break backwards compatibility to JSON-RPC API v4
if (item->HasProperty("artist_" + field + "_array"))
{
result[field] = item->GetProperty("artist_" + field + "_array");
continue;
}*/
if (item->HasProperty("artist_" + field))
{
result[field] = item->GetProperty("artist_" + field);
continue;
}
if (field == "fanart" && !item->HasPictureInfoTag())
{
CStdString fanart;
if (item->HasProperty("fanart_image"))
fanart = CTextureCache::Get().CheckAndCacheImage(item->GetProperty("fanart_image").asString());
if (fanart.empty())
fanart = item->GetCachedFanart();
if (!fanart.empty())
result["fanart"] = fanart.c_str();
continue;
}
if (item->HasVideoInfoTag() && item->GetVideoContentType() == VIDEODB_CONTENT_TVSHOWS)
{
if (item->GetVideoInfoTag()->m_iSeason < 0 && field == "season")
{
result[field] = (int)item->GetProperty("totalseasons").asInteger();
continue;
}
if (field == "watchedepisodes")
{
result[field] = (int)item->GetProperty("watchedepisodes").asInteger();
continue;
}
}
if (field == "lastmodified" && item->m_dateTime.IsValid())
{
result[field] = item->m_dateTime.GetAsLocalizedDateTime();
continue;
}
}
if (serialization.isMember(field) && (!result.isMember(field) || result[field].empty()))
result[field] = serialization[field];
}
}
示例10: HandleFileItem
void CFileItemHandler::HandleFileItem(const char *ID, bool allowFile, const char *resultname, CFileItemPtr item, const CVariant ¶meterObject, const CVariant &validFields, CVariant &result, bool append /* = true */)
{
CVariant object;
bool hasFileField = false;
bool hasThumbnailField = false;
if (item.get())
{
for (unsigned int i = 0; i < validFields.size(); i++)
{
CStdString field = validFields[i].asString();
if (field == "file")
hasFileField = true;
if (field == "thumbnail")
hasThumbnailField = true;
}
if (allowFile && hasFileField)
{
if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->GetPath().IsEmpty())
object["file"] = item->GetVideoInfoTag()->GetPath().c_str();
if (item->HasMusicInfoTag() && !item->GetMusicInfoTag()->GetURL().IsEmpty())
object["file"] = item->GetMusicInfoTag()->GetURL().c_str();
if (!object.isMember("file"))
object["file"] = item->GetPath().c_str();
}
if (ID)
{
if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetDatabaseId() > 0)
object[ID] = (int)item->GetMusicInfoTag()->GetDatabaseId();
else if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_iDbId > 0)
object[ID] = item->GetVideoInfoTag()->m_iDbId;
if (stricmp(ID, "id") == 0)
{
if (item->HasMusicInfoTag())
{
if (item->m_bIsFolder && item->IsAlbum())
object["type"] = "album";
else
object["type"] = "song";
}
else if (item->HasVideoInfoTag())
{
switch (item->GetVideoContentType())
{
case VIDEODB_CONTENT_EPISODES:
object["type"] = "episode";
break;
case VIDEODB_CONTENT_MUSICVIDEOS:
object["type"] = "musicvideo";
break;
case VIDEODB_CONTENT_MOVIES:
object["type"] = "movie";
break;
case VIDEODB_CONTENT_TVSHOWS:
object["type"] = "tvshow";
break;
default:
break;
}
}
else if (item->HasPictureInfoTag())
object["type"] = "picture";
if (!object.isMember("type"))
object["type"] = "unknown";
}
}
if (hasThumbnailField)
{
if (item->HasThumbnail())
object["thumbnail"] = CTextureCache::Get().CheckAndCacheImage(item->GetThumbnailImage());
else if (item->HasVideoInfoTag())
{ // TODO: Should the JSON-API return actual image URLs, virtual thumb URLs, or local URLs to the cached image?
// ATM we return the latter
CStdString thumbURL = CVideoThumbLoader::GetEmbeddedThumbURL(*item);
CStdString cachedThumb = CTextureCache::Get().GetCachedImage(thumbURL);
if (!cachedThumb.IsEmpty())
object["thumbnail"] = cachedThumb;
}
else if (item->HasPictureInfoTag())
{
CStdString thumb = CTextureCache::Get().CheckAndCacheImage(CTextureCache::GetWrappedThumbURL(item->GetPath()));
if (!thumb.empty())
object["thumbnail"] = thumb;
}
if (!object.isMember("thumbnail"))
object["thumbnail"] = "";
}
//.........这里部分代码省略.........