pragma ComponentBehavior: Bound import QtQuick import "Util.js" as Util Column { id: root required property Theme theme required property Media mediaService property var panelState: mediaService ? Util.parseJson(mediaService.stateJson(), { "activePlayer": {}, "players": [], "mediaPanelContract": {} }) : ({ "activePlayer": {}, "players": [], "mediaPanelContract": {} }) readonly property var player: panelState.activePlayer || ({}) readonly property var players: panelState.players || [] readonly property bool hasMedia: players.length > 0 readonly property var panel: panelState.mediaPanelContract || ({}) readonly property var transportActions: ["shuffle", "previous", "playPause", "next", "repeat"] function mmss(seconds) { const total = Math.max(0, Math.round(Number(seconds || 0))); const minutes = Math.floor(total / 60); const rest = String(total % 60).padStart(2, "0"); return `${minutes}:${rest}`; } function refreshFrom(text) { panelState = Util.parseJson(text, panelState); } function runAction(kind) { if (mediaService) refreshFrom(mediaService.action(kind)); } function seekByRatio(ratio) { const length = Math.max(0, Number(player.length || 0)); if (mediaService && length > 0) refreshFrom(mediaService.seek(Math.round(Math.max(0, Math.min(1, ratio)) * length))); } function selectPlayer(id) { if (mediaService) refreshFrom(mediaService.select(id)); } function actionIcon(kind) { if (kind === "shuffle") return "\uF074"; if (kind === "previous") return "󰒮"; if (kind === "playPause") return root.player.playbackState === "playing" ? "\uF04C" : "\uF04B"; if (kind === "next") return "󰒭"; if (kind === "repeat") return "\uF01E"; return "\uF001"; } function actionActive(kind) { return kind === "playPause" || kind === "shuffle" && root.player.shuffle || kind === "repeat" && root.player.repeat !== "none"; } function actionLabel(kind) { if (kind === "playPause") return root.player.playbackState === "playing" ? "pause" : "play"; return kind; } function roleColor(role) { if (!theme) return "white"; if (role === "ui.minor") return theme.ui.minor; if (role === "content.accent") return theme.content.accent; return theme.ui.accent; } spacing: 10 width: parent ? parent.width : 0 height: parent ? parent.height : 360 PopupCard { id: nowPlayingCard theme: root.theme padding: 0 objectName: "coverDetailsProgressTransport" visible: root.hasMedia width: parent.width height: Math.max(300, root.height - (root.players.length > 1 ? 42 : 0)) radius: 18 color: root.theme ? root.theme.withAlpha(root.theme.ui.backdrop, 0.72) : "transparent" border.width: 1 border.color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.22) : "transparent" clip: true Rectangle { anchors.fill: parent color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.05) : "transparent" } Rectangle { id: coverCard anchors.left: parent.left anchors.top: parent.top anchors.margins: 22 width: 178 height: 178 radius: 22 color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.2) : "transparent" border.width: 1 border.color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.35) : "transparent" clip: true Image { id: coverArt anchors.fill: parent visible: root.player.artAvailable && status === Image.Ready source: root.player.cover || "" fillMode: Image.PreserveAspectCrop asynchronous: true } Text { anchors.centerIn: parent visible: !coverArt.visible font.family: "Symbols Nerd Font Mono" font.pixelSize: 54 color: root.theme ? root.theme.ui.accent : "white" text: "\uF001" opacity: 0.9 } Rectangle { anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom height: 7 color: root.theme ? root.theme.ui.accent : "transparent" opacity: root.player.playbackState === "playing" ? 1 : 0.35 } } Column { anchors.left: coverCard.right anchors.leftMargin: 24 anchors.right: parent.right anchors.rightMargin: 24 anchors.top: parent.top anchors.topMargin: 28 spacing: 8 Row { width: parent.width spacing: 8 PopupBadge { id: stateBadge theme: root.theme text: root.player.playbackState === "playing" ? "now playing" : root.player.playbackState icon: root.player.playbackState === "playing" ? "●" : "" role: root.player.playbackState === "playing" ? "active" : "normal" } NuguText { theme: root.theme variant: "meta" text: root.player.identity || "mpris" width: parent.width - stateBadge.width - 16 opacity: 0.6 elide: Text.ElideRight } } NuguText { theme: root.theme variant: "title" text: root.player.title || root.player.identity || "untitled" width: parent.width font.pixelSize: 24 elide: Text.ElideRight } NuguText { theme: root.theme text: root.player.artist || "unknown artist" width: parent.width font.pixelSize: 16 opacity: root.player.artist ? 0.9 : 0.45 elide: Text.ElideRight } NuguText { theme: root.theme variant: "meta" text: root.player.album || "" visible: text.length > 0 width: parent.width opacity: 0.62 elide: Text.ElideRight } } Item { id: progressBlock anchors.left: parent.left anchors.right: parent.right anchors.leftMargin: 24 anchors.rightMargin: 24 anchors.bottom: transportRow.top anchors.bottomMargin: 22 height: 38 NuguText { anchors.left: parent.left anchors.top: parent.top theme: root.theme variant: "mono" text: root.mmss(root.player.position) opacity: 0.72 } NuguText { anchors.right: parent.right anchors.top: parent.top theme: root.theme variant: "mono" text: root.mmss(root.player.length) opacity: 0.72 } PopupSlider { objectName: "mpris-progress" anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom theme: root.theme value: Number(root.player.progress || 0) onMoved: value => root.seekByRatio(value) } } Row { id: transportRow objectName: "transportActions" anchors.horizontalCenter: parent.horizontalCenter anchors.bottom: parent.bottom anchors.bottomMargin: 22 spacing: 12 Repeater { model: root.transportActions delegate: PopupButton { id: transportButton required property string modelData readonly property bool isPrimary: modelData === "playPause" readonly property bool actionActive: root.actionActive(modelData) theme: root.theme width: isPrimary ? 64 : 46 height: isPrimary ? 64 : 46 radius: width / 2 anchors.verticalCenter: parent.verticalCenter icon: root.actionIcon(modelData) iconSize: isPrimary ? 25 : 19 role: isPrimary ? "primary" : "normal" checked: actionActive onClicked: root.runAction(modelData) } } } } Row { objectName: "playerSelectorRail" width: parent.width spacing: 6 visible: root.players.length > 1 Repeater { model: root.players delegate: PopupButton { id: playerButton required property var modelData readonly property bool active: modelData.id === root.player.id theme: root.theme height: 26 text: modelData.identity || modelData.id checked: active onClicked: root.selectPlayer(modelData.id) } } } Item { objectName: "mediaEmptyState" visible: !root.hasMedia width: parent.width height: 300 Column { anchors.centerIn: parent spacing: 12 Rectangle { anchors.horizontalCenter: parent.horizontalCenter width: 68 height: 68 radius: 34 color: root.theme ? root.theme.withAlpha(root.theme.ui.accent, 0.16) : "transparent" NuguText { anchors.centerIn: parent theme: root.theme variant: "title" selected: true text: "♪" } } NuguText { anchors.horizontalCenter: parent.horizontalCenter theme: root.theme variant: "title" text: "nothing playing" } NuguText { anchors.horizontalCenter: parent.horizontalCenter theme: root.theme variant: "meta" text: "start a track — controls appear here" } } } }