Skip to content

Commit f630235

Browse files
authored
Allow SlimBrowse to support duration
SlimBrowse currently does not seem to support duration values passed by plugins to Material skin. This, together with a trial trivial change to LMS (LMS-Community/slimserver#1348) allows Material to display track duration and total duration. Works with lms-plugin-tidal and Spotty-Plugin.
1 parent 1240d08 commit f630235

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

MaterialSkin/HTML/material/html/js/browse-resp.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ function parseBrowseResp(data, parent, options, cacheKey, parentCommand, parentG
142142
var maybeAllowGrid = command!="trackstat"; // && !isFavorites; // && command!="playhistory";
143143
var numImages = 0;
144144
var numTracks = 0;
145+
var totalDuration = 0; // support for total duration if duration has been passed as a parameter
145146

146147
resp.isMusicMix = MIXER_APPS.has(command) && data.params[1].length>0 && (data.params[1][1]=="mix" || data.params[1][1]=="list");
147148
resp.canUseGrid = maybeAllowGrid && (isRadiosTop || isAppsTop || isBmf || isDisksAndFolders || (data.result.window && data.result.window.windowStyle && (data.result.window.windowStyle=="icon_list" || data.result.window.windowStyle=="home_menu"))) ? true : false;
@@ -693,7 +694,12 @@ function parseBrowseResp(data, parent, options, cacheKey, parentCommand, parentG
693694
i.icon = undefined;
694695
haveWithoutIcons = true;
695696
}
696-
697+
698+
// show duration if duration has been passed as a parameter
699+
i.duration = i.duration>0 ? i.duration : undefined,
700+
i.durationStr = i.duration>0 ? formatSeconds(i.duration) : undefined,
701+
totalDuration += i.duration>0 ? i.duration : 0;
702+
697703
resp.items.push(i);
698704
// If this is a "text" item with an image then treat as a standard actionable item
699705
if ("text"==i.type && (undefined!=i.image || undefined!=i.icon || undefined!=i.svg)) {
@@ -929,6 +935,11 @@ function parseBrowseResp(data, parent, options, cacheKey, parentCommand, parentG
929935
}
930936
}
931937
}
938+
939+
// show total duration if duration has been passed as a parameter
940+
if (totalDuration>0) {
941+
resp.subtitle+=SEPARATOR+formatSeconds(totalDuration);
942+
}
932943
} else if (data.result.artists_loop) {
933944
var type = 0;
934945
var stdItem = parent && parent.id.startsWith("mmw") ? STD_ITEM_WORK_COMPOSER : STD_ITEM_ARTIST;

0 commit comments

Comments
 (0)