bool CPVRGUIInfo::GetListItemAndPlayerLabel(const CFileItem *item, const CGUIInfo &info, std::string &strValue) const { const CPVRTimerInfoTagPtr timer = item->GetPVRTimerInfoTag(); if (timer) { switch (info.m_info) { case LISTITEM_DATE: strValue = timer->Summary(); return true; case LISTITEM_STARTDATE: strValue = timer->StartAsLocalTime().GetAsLocalizedDate(true); return true; case LISTITEM_STARTTIME: strValue = timer->StartAsLocalTime().GetAsLocalizedTime("", false); return true; case LISTITEM_ENDDATE: strValue = timer->EndAsLocalTime().GetAsLocalizedDate(true); return true; case LISTITEM_ENDTIME: strValue = timer->EndAsLocalTime().GetAsLocalizedTime("", false); return true; case LISTITEM_TITLE: strValue = timer->Title(); return true; case LISTITEM_COMMENT: strValue = timer->GetStatus(); return true; case LISTITEM_TIMERTYPE: strValue = timer->GetTypeAsString(); return true; case LISTITEM_CHANNEL_NAME: strValue = timer->ChannelName(); return true; case LISTITEM_EPG_EVENT_TITLE: case LISTITEM_EPG_EVENT_ICON: case LISTITEM_GENRE: case LISTITEM_PLOT: case LISTITEM_PLOT_OUTLINE: case LISTITEM_DURATION: case LISTITEM_ORIGINALTITLE: case LISTITEM_YEAR: case LISTITEM_SEASON: case LISTITEM_EPISODE: case LISTITEM_EPISODENAME: case LISTITEM_DIRECTOR: case LISTITEM_CHANNEL_NUMBER: case LISTITEM_PREMIERED: break; // obtain value from channel/epg default: return false; } } const CPVRRecordingPtr recording(item->GetPVRRecordingInfoTag()); if (recording) { // Note: CPVRRecoding is derived from CVideoInfoTag. All base class properties will be handled // by CVideoGUIInfoProvider. Only properties introduced by CPVRRecording need to be handled here. switch (info.m_info) { case LISTITEM_DATE: strValue = recording->RecordingTimeAsLocalTime().GetAsLocalizedDateTime(false, false); return true; case LISTITEM_STARTDATE: strValue = recording->RecordingTimeAsLocalTime().GetAsLocalizedDate(true); return true; case VIDEOPLAYER_STARTTIME: case LISTITEM_STARTTIME: strValue = recording->RecordingTimeAsLocalTime().GetAsLocalizedTime("", false); return true; case LISTITEM_ENDDATE: strValue = recording->EndTimeAsLocalTime().GetAsLocalizedDate(true); return true; case VIDEOPLAYER_ENDTIME: case LISTITEM_ENDTIME: strValue = recording->EndTimeAsLocalTime().GetAsLocalizedTime("", false); return true; case LISTITEM_EXPIRATION_DATE: if (recording->HasExpirationTime()) { strValue = recording->ExpirationTimeAsLocalTime().GetAsLocalizedDate(false); return true; } break; case LISTITEM_EXPIRATION_TIME: if (recording->HasExpirationTime()) { strValue = recording->ExpirationTimeAsLocalTime().GetAsLocalizedTime("", false);; return true; } break; case VIDEOPLAYER_EPISODENAME: case LISTITEM_EPISODENAME: strValue = recording->EpisodeName(); return true; case VIDEOPLAYER_CHANNEL_NAME: case LISTITEM_CHANNEL_NAME: strValue = recording->m_strChannelName; return true; case VIDEOPLAYER_CHANNEL_NUMBER: case LISTITEM_CHANNEL_NUMBER: { const CPVRChannelPtr channel = recording->Channel(); if (channel) { strValue = channel->ChannelNumber().FormattedChannelNumber(); return true; } break; } case VIDEOPLAYER_CHANNEL_GROUP: { CSingleLock lock(m_critSection); strValue = recording->IsRadio() ? m_strPlayingRadioGroup : m_strPlayingTVGroup; return true; } } return false; } CPVREpgInfoTagPtr epgTag; CPVRChannelPtr channel; if (item->IsPVRChannel() || item->IsEPG() || item->IsPVRTimer()) { CPVRItem pvrItem(item); channel = pvrItem.GetChannel(); switch (info.m_info) { case VIDEOPLAYER_NEXT_TITLE: case VIDEOPLAYER_NEXT_GENRE: case VIDEOPLAYER_NEXT_PLOT: case VIDEOPLAYER_NEXT_PLOT_OUTLINE: case VIDEOPLAYER_NEXT_STARTTIME: case VIDEOPLAYER_NEXT_ENDTIME: case VIDEOPLAYER_NEXT_DURATION: case LISTITEM_NEXT_TITLE: case LISTITEM_NEXT_GENRE: case LISTITEM_NEXT_PLOT: case LISTITEM_NEXT_PLOT_OUTLINE: case LISTITEM_NEXT_STARTDATE: case LISTITEM_NEXT_STARTTIME: case LISTITEM_NEXT_ENDDATE: case LISTITEM_NEXT_ENDTIME: case LISTITEM_NEXT_DURATION: // next playing event epgTag = pvrItem.GetNextEpgInfoTag(); break; default: // now playing event epgTag = pvrItem.GetEpgInfoTag(); break; } switch (info.m_info) { // special handling for channels without epg or with radio rds data case PLAYER_TITLE: case VIDEOPLAYER_TITLE: case LISTITEM_TITLE: case VIDEOPLAYER_NEXT_TITLE: case LISTITEM_NEXT_TITLE: case LISTITEM_EPG_EVENT_TITLE: // Note: in difference to LISTITEM_TITLE, LISTITEM_EPG_EVENT_TITLE returns the title // associated with the epg event of a timer, if any, and not the title of the timer. if (epgTag) strValue = epgTag->Title(); if (strValue.empty() && !CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_EPG_HIDENOINFOAVAILABLE)) strValue = g_localizeStrings.Get(19055); // no information available return true; } } if (epgTag) { switch (info.m_info) { case VIDEOPLAYER_GENRE: case LISTITEM_GENRE: case VIDEOPLAYER_NEXT_GENRE: case LISTITEM_NEXT_GENRE: strValue = epgTag->GetGenresLabel(); return true; case VIDEOPLAYER_PLOT: case LISTITEM_PLOT: case VIDEOPLAYER_NEXT_PLOT: case LISTITEM_NEXT_PLOT: strValue = epgTag->Plot(); return true; case VIDEOPLAYER_PLOT_OUTLINE: case LISTITEM_PLOT_OUTLINE: case VIDEOPLAYER_NEXT_PLOT_OUTLINE: case LISTITEM_NEXT_PLOT_OUTLINE: strValue = epgTag->PlotOutline(); return true; case LISTITEM_DATE: strValue = epgTag->StartAsLocalTime().GetAsLocalizedDateTime(false, false); return true; case LISTITEM_STARTDATE: case LISTITEM_NEXT_STARTDATE: strValue = epgTag->StartAsLocalTime().GetAsLocalizedDate(true); return true; case VIDEOPLAYER_STARTTIME: case VIDEOPLAYER_NEXT_STARTTIME: case LISTITEM_STARTTIME: case LISTITEM_NEXT_STARTTIME: strValue = epgTag->StartAsLocalTime().GetAsLocalizedTime("", false); return true; case LISTITEM_ENDDATE: case LISTITEM_NEXT_ENDDATE: strValue = epgTag->EndAsLocalTime().GetAsLocalizedDate(true); return true; case VIDEOPLAYER_ENDTIME: case VIDEOPLAYER_NEXT_ENDTIME: case LISTITEM_ENDTIME: case LISTITEM_NEXT_ENDTIME: strValue = epgTag->EndAsLocalTime().GetAsLocalizedTime("", false); return true; // note: for some reason, there is no VIDEOPLAYER_DURATION case LISTITEM_DURATION: case VIDEOPLAYER_NEXT_DURATION: case LISTITEM_NEXT_DURATION: if (epgTag->GetDuration() > 0) { strValue = StringUtils::SecondsToTimeString(epgTag->GetDuration(), static_cast<TIME_FORMAT>(info.GetData4())); return true; } return false; case VIDEOPLAYER_IMDBNUMBER: case LISTITEM_IMDBNUMBER: strValue = epgTag->IMDBNumber(); return true; case VIDEOPLAYER_ORIGINALTITLE: case LISTITEM_ORIGINALTITLE: strValue = epgTag->OriginalTitle(); return true; case VIDEOPLAYER_YEAR: case LISTITEM_YEAR: if (epgTag->Year() > 0) { strValue = StringUtils::Format("%i", epgTag->Year()); return true; } return false; case VIDEOPLAYER_SEASON: case LISTITEM_SEASON: if (epgTag->SeriesNumber() > 0) { strValue = StringUtils::Format("%i", epgTag->SeriesNumber()); return true; } return false; case VIDEOPLAYER_EPISODE: case LISTITEM_EPISODE: if (epgTag->EpisodeNumber() > 0) { if (epgTag->SeriesNumber() == 0) // prefix episode with 'S' strValue = StringUtils::Format("S%i", epgTag->EpisodeNumber()); else strValue = StringUtils::Format("%i", epgTag->EpisodeNumber()); return true; } return false; case VIDEOPLAYER_EPISODENAME: case LISTITEM_EPISODENAME: strValue = epgTag->EpisodeName(); return true; case VIDEOPLAYER_CAST: case LISTITEM_CAST: strValue = epgTag->GetCastLabel(); return true; case VIDEOPLAYER_DIRECTOR: case LISTITEM_DIRECTOR: strValue = epgTag->GetDirectorsLabel(); return true; case VIDEOPLAYER_WRITER: case LISTITEM_WRITER: strValue = epgTag->GetWritersLabel(); return true; case LISTITEM_EPG_EVENT_ICON: strValue = epgTag->Icon(); return true; case VIDEOPLAYER_PARENTAL_RATING: case LISTITEM_PARENTALRATING: if (epgTag->ParentalRating() > 0) { strValue = StringUtils::Format("%i", epgTag->ParentalRating()); return true; } return false; case LISTITEM_PREMIERED: if (epgTag->FirstAiredAsLocalTime().IsValid()) { strValue = epgTag->FirstAiredAsLocalTime().GetAsLocalizedDate(true); return true; } return false; } } if (channel) { switch (info.m_info) { case MUSICPLAYER_CHANNEL_NAME: { const std::shared_ptr<CPVRRadioRDSInfoTag> rdsTag = channel->GetRadioRDSInfoTag(); if (rdsTag) { strValue = rdsTag->GetProgStation(); if (!strValue.empty()) return true; } // fall-thru is intended } case VIDEOPLAYER_CHANNEL_NAME: case LISTITEM_CHANNEL_NAME: strValue = channel->ChannelName(); return true; case MUSICPLAYER_CHANNEL_NUMBER: case VIDEOPLAYER_CHANNEL_NUMBER: case LISTITEM_CHANNEL_NUMBER: strValue = channel->ChannelNumber().FormattedChannelNumber(); return true; case MUSICPLAYER_CHANNEL_GROUP: case VIDEOPLAYER_CHANNEL_GROUP: { CSingleLock lock(m_critSection); strValue = channel->IsRadio() ? m_strPlayingRadioGroup : m_strPlayingTVGroup; return true; } } } return false; }
bool CMusicGUIInfo::GetLabel(std::string& value, const CFileItem *item, int contextWindow, const CGUIInfo &info, std::string *fallback) const { if (info.GetData1() && info.m_info >= MUSICPLAYER_TITLE && info.m_info <= MUSICPLAYER_ALBUM_ARTIST) return GetPlaylistInfo(value, info); const CMusicInfoTag* tag = item->GetMusicInfoTag(); if (tag) { switch (info.m_info) { ///////////////////////////////////////////////////////////////////////////////////////////// // PLAYER_* / MUSICPLAYER_* / LISTITEM_* ///////////////////////////////////////////////////////////////////////////////////////////// case PLAYER_PATH: case PLAYER_FILENAME: case PLAYER_FILEPATH: value = tag->GetURL(); if (value.empty()) value = item->GetPath(); value = GUIINFO::GetFileInfoLabelValueFromPath(info.m_info, value); return true; case PLAYER_TITLE: value = tag->GetTitle(); return !value.empty(); case MUSICPLAYER_TITLE: value = tag->GetTitle(); if (value.empty()) value = item->GetLabel(); if (value.empty()) value = CUtil::GetTitleFromPath(item->GetPath()); return true; case LISTITEM_TITLE: value = tag->GetTitle(); return true; case MUSICPLAYER_PLAYCOUNT: case LISTITEM_PLAYCOUNT: if (tag->GetPlayCount() > 0) { value = StringUtils::Format("%i", tag->GetPlayCount()); return true; } break; case MUSICPLAYER_LASTPLAYED: case LISTITEM_LASTPLAYED: { const CDateTime dateTime = tag->GetLastPlayed(); if (dateTime.IsValid()) { value = dateTime.GetAsLocalizedDate(); return true; } break; } case MUSICPLAYER_TRACK_NUMBER: case LISTITEM_TRACKNUMBER: if (tag->Loaded() && tag->GetTrackNumber() > 0) { value = StringUtils::Format("%02i", tag->GetTrackNumber()); return true; } break; case MUSICPLAYER_DISC_NUMBER: case LISTITEM_DISC_NUMBER: if (tag->GetDiscNumber() > 0) { value = StringUtils::Format("%i", tag->GetDiscNumber()); return true; } break; case MUSICPLAYER_ARTIST: case LISTITEM_ARTIST: value = tag->GetArtistString(); return true; case MUSICPLAYER_ALBUM_ARTIST: case LISTITEM_ALBUM_ARTIST: value = tag->GetAlbumArtistString(); return true; case MUSICPLAYER_CONTRIBUTORS: case LISTITEM_CONTRIBUTORS: if (tag->HasContributors()) { value = tag->GetContributorsText(); return true; } break; case MUSICPLAYER_CONTRIBUTOR_AND_ROLE: case LISTITEM_CONTRIBUTOR_AND_ROLE: if (tag->HasContributors()) { value = tag->GetContributorsAndRolesText(); return true; } break; case MUSICPLAYER_ALBUM: case LISTITEM_ALBUM: value = tag->GetAlbum(); return true; case MUSICPLAYER_YEAR: case LISTITEM_YEAR: value = tag->GetYearString(); return true; case MUSICPLAYER_GENRE: case LISTITEM_GENRE: value = StringUtils::Join(tag->GetGenre(), CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_musicItemSeparator); return true; case MUSICPLAYER_LYRICS: value = tag->GetLyrics(); return true; case MUSICPLAYER_RATING: case LISTITEM_RATING: { float rating = tag->GetRating(); if (rating > 0.f) { value = StringUtils::FormatNumber(rating); return true; } break; } case MUSICPLAYER_RATING_AND_VOTES: case LISTITEM_RATING_AND_VOTES: { float rating = tag->GetRating(); if (rating > 0.f) { int votes = tag->GetVotes(); if (votes <= 0) value = StringUtils::FormatNumber(rating); else value = StringUtils::Format(g_localizeStrings.Get(20350).c_str(), StringUtils::FormatNumber(rating).c_str(), StringUtils::FormatNumber(votes).c_str()); return true; } break; } case MUSICPLAYER_USER_RATING: case LISTITEM_USER_RATING: if (tag->GetUserrating() > 0) { value = StringUtils::Format("%i", tag->GetUserrating()); return true; } break; case MUSICPLAYER_COMMENT: case LISTITEM_COMMENT: value = tag->GetComment(); return true; case MUSICPLAYER_MOOD: case LISTITEM_MOOD: value = tag->GetMood(); return true; case LISTITEM_DBTYPE: value = tag->GetType(); return true; case MUSICPLAYER_DBID: case LISTITEM_DBID: { int dbId = tag->GetDatabaseId(); if (dbId > -1) { value = StringUtils::Format("%i", dbId); return true; } break; } case PLAYER_DURATION: if (!g_application.GetAppPlayer().IsPlayingAudio()) break; // fall-thru is intended. case MUSICPLAYER_DURATION: case LISTITEM_DURATION: { int iDuration = tag->GetDuration(); if (iDuration > 0) { value = StringUtils::SecondsToTimeString(iDuration, static_cast<TIME_FORMAT>(info.GetData4())); return true; } break; } ///////////////////////////////////////////////////////////////////////////////////////////// // LISTITEM_* ///////////////////////////////////////////////////////////////////////////////////////////// case LISTITEM_PROPERTY: if (StringUtils::StartsWithNoCase(info.GetData3(), "Role.")) { // "Role.xxxx" properties are held in music tag std::string property = info.GetData3(); property.erase(0, 5); //Remove Role. value = tag->GetArtistStringForRole(property); return true; } break; case LISTITEM_VOTES: value = StringUtils::FormatNumber(tag->GetVotes()); return true; case LISTITEM_FILENAME: case LISTITEM_FILE_EXTENSION: if (item->IsMusicDb()) value = URIUtils::GetFileName(tag->GetURL()); else if (item->HasVideoInfoTag()) // special handling for music videos, which have both a videotag and a musictag break; else value = URIUtils::GetFileName(item->GetPath()); if (info.m_info == LISTITEM_FILE_EXTENSION) { std::string strExtension = URIUtils::GetExtension(value); value = StringUtils::TrimLeft(strExtension, "."); } return true; case LISTITEM_FOLDERNAME: case LISTITEM_PATH: if (item->IsMusicDb()) value = URIUtils::GetDirectory(tag->GetURL()); else if (item->HasVideoInfoTag()) // special handling for music videos, which have both a videotag and a musictag break; else URIUtils::GetParentPath(item->GetPath(), value); value = CURL(value).GetWithoutUserDetails(); if (info.m_info == LISTITEM_FOLDERNAME) { URIUtils::RemoveSlashAtEnd(value); value = URIUtils::GetFileName(value); } return true; case LISTITEM_FILENAME_AND_PATH: if (item->IsMusicDb()) value = tag->GetURL(); else if (item->HasVideoInfoTag()) // special handling for music videos, which have both a videotag and a musictag break; else value = item->GetPath(); value = CURL(value).GetWithoutUserDetails(); return true; } } switch (info.m_info) { /////////////////////////////////////////////////////////////////////////////////////////////// // MUSICPLAYER_* /////////////////////////////////////////////////////////////////////////////////////////////// case MUSICPLAYER_PROPERTY: value = item->GetProperty(info.GetData3()).asString(); return true; case MUSICPLAYER_PLAYLISTLEN: if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST_MUSIC) { value = GUIINFO::GetPlaylistLabel(PLAYLIST_LENGTH); return true; } break; case MUSICPLAYER_PLAYLISTPOS: if (CServiceBroker::GetPlaylistPlayer().GetCurrentPlaylist() == PLAYLIST_MUSIC) { value = GUIINFO::GetPlaylistLabel(PLAYLIST_POSITION); return true; } break; case MUSICPLAYER_COVER: if (g_application.GetAppPlayer().IsPlayingAudio()) { if (fallback) *fallback = "DefaultAlbumCover.png"; value = item->HasArt("thumb") ? item->GetArt("thumb") : "DefaultAlbumCover.png"; return true; } break; case MUSICPLAYER_BITRATE: { int iBitrate = m_audioInfo.bitrate; if (iBitrate > 0) { value = StringUtils::Format("%li", std::lrint(static_cast<double>(iBitrate) / 1000.0)); return true; } break; } case MUSICPLAYER_CHANNELS: { int iChannels = m_audioInfo.channels; if (iChannels > 0) { value = StringUtils::Format("%i", iChannels); return true; } break; } case MUSICPLAYER_BITSPERSAMPLE: { int iBPS = m_audioInfo.bitspersample; if (iBPS > 0) { value = StringUtils::Format("%i", iBPS); return true; } break; } case MUSICPLAYER_SAMPLERATE: { int iSamplerate = m_audioInfo.samplerate; if (iSamplerate > 0) { value = StringUtils::Format("%.5g", static_cast<double>(iSamplerate) / 1000.0); return true; } break; } case MUSICPLAYER_CODEC: value = StringUtils::Format("%s", m_audioInfo.codecName.c_str()); return true; } /////////////////////////////////////////////////////////////////////////////////////////////// // MUSICPM_* /////////////////////////////////////////////////////////////////////////////////////////////// if (GetPartyModeLabel(value, info)) return true; return false; }