From d625f1791b2e2e97d86f7fc3ebf3073c0c323a9b Mon Sep 17 00:00:00 2001
From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Date: Sun, 2 Mar 2025 17:40:36 +1100
Subject: app: media data requests

Allow querying media player data
---
 app.tsx | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

(limited to 'app.tsx')

diff --git a/app.tsx b/app.tsx
index 4f59115..7d34231 100644
--- a/app.tsx
+++ b/app.tsx
@@ -67,7 +67,13 @@ App.start({
         else if (request === "media next") Players.get_default().lastPlayer?.next();
         else if (request === "media previous") Players.get_default().lastPlayer?.previous();
         else if (request === "media stop") Players.get_default().lastPlayer?.stop();
-        else if (request.startsWith("brightness")) {
+        else if (request.startsWith("media")) {
+            const player = Players.get_default().lastPlayer;
+            const key = request.split(" ")[1];
+            if (player === null) return res("No available players");
+            if (key in player) return res(player[key as keyof typeof player]);
+            return res(`Invalid key: ${key}`);
+        } else if (request.startsWith("brightness")) {
             const value = request.split(" ")[1];
             const num = parseFloat(value) / (value.includes("%") ? 100 : 1);
             if (isNaN(num)) return res("Syntax: brightness <value>[%][+ | -]");
-- 
cgit v1.2.3-freya

