From c8287f18582091f6f51bd291987bd77fb2c292e2 Mon Sep 17 00:00:00 2001 From: DaveTBlake Date: Fri, 27 Sep 2019 12:53:15 +0100 Subject: [PATCH] Fix musicplayer.offset(n).xxx and musicplayer.position(n).xxx Rearrange musicplayer defines to group infolabels that work with offset and position for range checking separately from others e.g. infobools. Define range. --- xbmc/GUIInfoManager.cpp | 4 +-- xbmc/guilib/guiinfo/GUIInfoLabels.h | 48 ++++++++++++++++------------ xbmc/guilib/guiinfo/MusicGUIInfo.cpp | 4 ++- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/xbmc/GUIInfoManager.cpp b/xbmc/GUIInfoManager.cpp index 683d0f71b56a4..8d45a4ac6150f 100644 --- a/xbmc/GUIInfoManager.cpp +++ b/xbmc/GUIInfoManager.cpp @@ -9027,13 +9027,13 @@ int CGUIInfoManager::TranslateSingleString(const std::string &strCondition, bool { int position = atoi(info[1].param().c_str()); int value = TranslateMusicPlayerString(info[2].name); // musicplayer.position(foo).bar - return AddMultiInfo(CGUIInfo(value, 0, position)); + return AddMultiInfo(CGUIInfo(value, 2, position)); // 2 => absolute (0 used for not set) } else if (info[1].name == "offset") { int position = atoi(info[1].param().c_str()); int value = TranslateMusicPlayerString(info[2].name); // musicplayer.offset(foo).bar - return AddMultiInfo(CGUIInfo(value, 1, position)); + return AddMultiInfo(CGUIInfo(value, 1, position)); // 1 => relative } } else if (info[0].name == "container") diff --git a/xbmc/guilib/guiinfo/GUIInfoLabels.h b/xbmc/guilib/guiinfo/GUIInfoLabels.h index 47c5831d293b3..d891c01c9213d 100644 --- a/xbmc/guilib/guiinfo/GUIInfoLabels.h +++ b/xbmc/guilib/guiinfo/GUIInfoLabels.h @@ -152,6 +152,8 @@ #define NETWORK_DNS2_ADDRESS 197 #define NETWORK_DHCP_ADDRESS 198 + +// Keep musicplayer infolabels that work with offset and position together #define MUSICPLAYER_TITLE 200 #define MUSICPLAYER_ALBUM 201 #define MUSICPLAYER_ARTIST 202 @@ -171,27 +173,31 @@ #define MUSICPLAYER_RATING 219 #define MUSICPLAYER_COMMENT 220 #define MUSICPLAYER_LYRICS 221 -#define MUSICPLAYER_HASPREVIOUS 222 -#define MUSICPLAYER_HASNEXT 223 -#define MUSICPLAYER_EXISTS 224 -#define MUSICPLAYER_PLAYLISTPLAYING 225 -#define MUSICPLAYER_ALBUM_ARTIST 226 -#define MUSICPLAYER_PLAYCOUNT 227 -#define MUSICPLAYER_LASTPLAYED 228 -#define MUSICPLAYER_CHANNEL_NAME 229 -// unused 230 -#define MUSICPLAYER_CHANNEL_GROUP 231 -// unused 232 -#define MUSICPLAYER_CHANNEL_NUMBER 233 -#define MUSICPLAYER_CONTENT 234 -#define MUSICPLAYER_USER_RATING 235 -#define MUSICPLAYER_RATING_AND_VOTES 236 -#define MUSICPLAYER_VOTES 237 -#define MUSICPLAYER_MOOD 238 -#define MUSICPLAYER_CONTRIBUTORS 239 -#define MUSICPLAYER_CONTRIBUTOR_AND_ROLE 240 -#define MUSICPLAYER_DBID 241 -#define MUSICPLAYER_PROPERTY 242 +#define MUSICPLAYER_ALBUM_ARTIST 222 +#define MUSICPLAYER_PLAYCOUNT 223 +#define MUSICPLAYER_LASTPLAYED 224 +#define MUSICPLAYER_USER_RATING 225 +#define MUSICPLAYER_RATING_AND_VOTES 226 +#define MUSICPLAYER_VOTES 227 +#define MUSICPLAYER_MOOD 228 +#define MUSICPLAYER_CONTRIBUTORS 229 +#define MUSICPLAYER_CONTRIBUTOR_AND_ROLE 230 +#define MUSICPLAYER_DBID 231 + +// Range of musicplayer infolabels that work with offset and position +#define MUSICPLAYER_OFFSET_POSITION_FIRST MUSICPLAYER_TITLE +#define MUSICPLAYER_OFFSET_POSITION_LAST MUSICPLAYER_DBID + +#define MUSICPLAYER_PROPERTY 236 +#define MUSICPLAYER_CHANNEL_NAME 237 +#define MUSICPLAYER_CHANNEL_GROUP 238 +#define MUSICPLAYER_CHANNEL_NUMBER 239 +// Musicplayer infobools +#define MUSICPLAYER_HASPREVIOUS 240 +#define MUSICPLAYER_HASNEXT 241 +#define MUSICPLAYER_EXISTS 242 +#define MUSICPLAYER_PLAYLISTPLAYING 243 +#define MUSICPLAYER_CONTENT 244 #define VIDEOPLAYER_AUDIO_BITRATE 248 #define VIDEOPLAYER_VIDEO_BITRATE 249 diff --git a/xbmc/guilib/guiinfo/MusicGUIInfo.cpp b/xbmc/guilib/guiinfo/MusicGUIInfo.cpp index 121c5fb80300a..c33f5af5c5577 100644 --- a/xbmc/guilib/guiinfo/MusicGUIInfo.cpp +++ b/xbmc/guilib/guiinfo/MusicGUIInfo.cpp @@ -76,7 +76,9 @@ bool CMusicGUIInfo::InitCurrentItem(CFileItem *item) 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) + // For musicplayer "offset" and "position" info labels check playlist + if (info.GetData1() && info.m_info >= MUSICPLAYER_OFFSET_POSITION_FIRST && + info.m_info <= MUSICPLAYER_OFFSET_POSITION_LAST) return GetPlaylistInfo(value, info); const CMusicInfoTag* tag = item->GetMusicInfoTag();