From 55e2ea353fca84b8307fd0f1482fa7cb1f5105f6 Mon Sep 17 00:00:00 2001 From: Wolfgang Kulhanek Date: Thu, 16 Oct 2025 14:12:28 +0200 Subject: [PATCH] Implement reportPlaySeconds and reportPlayStatus --- src/smapi.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/smapi.ts b/src/smapi.ts index 9fcf13b..a68c84a 100644 --- a/src/smapi.ts +++ b/src/smapi.ts @@ -1221,6 +1221,45 @@ function bindSmapiSoapServiceToExpress( .then((_) => ({ setPlayedSecondsResult: {}, })), + + reportPlaySeconds: async ( + { id, seconds }: { id: string; seconds: string }, + _, + soapyHeaders: SoapyHeaders, + { headers }: Pick + ) => + login(soapyHeaders?.credentials, headers) + .then(splitId(id)) + .then(({ type, typeId }) => { + if (type === "track") { + logger.debug(`reportPlaySeconds called for track ${typeId}, seconds: ${seconds}`); + // Return interval of 30 seconds for next update + return Promise.resolve(true); + } + return Promise.resolve(true); + }) + .then((_) => ({ + reportPlaySecondsResult: { interval: 30 }, + })), + + reportPlayStatus: async ( + { id, status }: { id: string; status: string }, + _, + soapyHeaders: SoapyHeaders, + { headers }: Pick + ) => + login(soapyHeaders?.credentials, headers) + .then(splitId(id)) + .then(({ musicLibrary, type, typeId }) => { + if (type === "track") { + logger.info(`reportPlayStatus called for track ${typeId}, status: ${status}`); + if (status === "PLAY_START" || status === "PAUSED_PLAYBACK") { + return musicLibrary.nowPlaying(typeId); + } + } + return Promise.resolve(true); + }) + .then((_) => ({})), }, }, },