From 4d047909fc86a6e7199440732abfe2e053d95d0b Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Mon, 22 Jun 2026 14:55:05 -0400 Subject: [PATCH] fix playback speed message in lounge --- .../Services/LoungeService/LoungeApi.bs | 27 +++++++++++++++++++ .../Services/LoungeService/LoungeConstants.bs | 1 + .../Services/LoungeService/LoungeMessages.bs | 12 +++++---- .../src/components/VideoPlayer/Lounge.bs | 5 ++-- 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/playlet-lib/src/components/Services/LoungeService/LoungeApi.bs b/playlet-lib/src/components/Services/LoungeService/LoungeApi.bs index 60585bd6..0f1c175b 100644 --- a/playlet-lib/src/components/Services/LoungeService/LoungeApi.bs +++ b/playlet-lib/src/components/Services/LoungeService/LoungeApi.bs @@ -86,6 +86,7 @@ class LoungeApi commandHandlers[COMMAND_TYPE_STOP_VIDEO] = m.HandleStopVideo commandHandlers[COMMAND_TYPE_SEEK_TO] = m.HandleSeekTo commandHandlers[COMMAND_TYPE_SET_PLAYBACK_SPEED] = m.HandleSetPlaybackSpeed + commandHandlers[COMMAND_TYPE_GET_PLAYBACK_SPEED] = m.HandleGetPlaybackSpeed for each key in commandHandlers m[COMMAND_HANDLER_PREFIX + key] = commandHandlers[key] @@ -508,6 +509,11 @@ class LoungeApi speed = 1.0 end if + content = player.content + if content <> invalid and content.live = true + return + end if + currentSpeed = ValidFloat(player.playbackSpeed) if Abs(currentSpeed - speed) < 0.001 @@ -534,6 +540,27 @@ class LoungeApi messagesToSend.Push(LoungeMessages.OnPlaybackSpeedChanged(speed, true)) end function + function HandleGetPlaybackSpeed(commandId as integer, _commandType as string, _commandArgs as object, messagesToSend as object) as void + player = m.videoQueueNode.player + if player = invalid + return + end if + + if not player.hasField("playbackSpeed") + LogWarn("Video node does not support 'playbackSpeed' field on this device, ignoring getPlaybackSpeed command") + return + end if + + speed = ValidFloat(player.playbackSpeed) + if speed <= 0 + speed = 1.0 + end if + + message = LoungeMessages.OnPlaybackSpeedChanged(speed) + message["commandId"] = commandId + messagesToSend.Push(message) + end function + function SendMessages(messages as object, loungeData = invalid as object) as void if messages.Count() = 0 return diff --git a/playlet-lib/src/components/Services/LoungeService/LoungeConstants.bs b/playlet-lib/src/components/Services/LoungeService/LoungeConstants.bs index 534b7674..736a43e7 100644 --- a/playlet-lib/src/components/Services/LoungeService/LoungeConstants.bs +++ b/playlet-lib/src/components/Services/LoungeService/LoungeConstants.bs @@ -34,6 +34,7 @@ const COMMAND_TYPE_GET_RECEIVER_STATUS = "getReceiverStatus" const COMMAND_TYPE_SEND_DEBUG_COMMAND = "sendDebugCommand" const COMMAND_TYPE_SET_AUTOPLAY_MODE = "setAutoplayMode" const COMMAND_TYPE_SET_PLAYBACK_SPEED = "setPlaybackSpeed" +const COMMAND_TYPE_GET_PLAYBACK_SPEED = "getPlaybackSpeed" ' Special commands const COMMAND_TYPE_SESSION_ID = "c" const COMMAND_TYPE_G_SESSION_ID = "S" diff --git a/playlet-lib/src/components/Services/LoungeService/LoungeMessages.bs b/playlet-lib/src/components/Services/LoungeService/LoungeMessages.bs index f62ef599..cd8a131a 100644 --- a/playlet-lib/src/components/Services/LoungeService/LoungeMessages.bs +++ b/playlet-lib/src/components/Services/LoungeService/LoungeMessages.bs @@ -15,16 +15,18 @@ namespace LoungeMessages return message end function - function OnPlaybackSpeedChanged(speed as float, isContentSupportVSP as boolean) as object + function OnPlaybackSpeedChanged(speed as float, isContentSupportVSP = invalid as dynamic) as object message = { commandType: COMMAND_ON_PLAYBACK_SPEED_CHANGED } commandArgs = {} commandArgs[FIELD_PLAYBACK_SPEED] = speed - commandArgs[FIELD_PLAYBACK_SPEED_INFO] = FormatJson({ - "playbackSpeed": speed - "isContentSupportVSP": isContentSupportVSP - }) + if isContentSupportVSP <> invalid + commandArgs[FIELD_PLAYBACK_SPEED_INFO] = FormatJson({ + "playbackSpeed": speed + "isContentSupportVSP": isContentSupportVSP + }) + end if message.commandArgs = commandArgs return message end function diff --git a/playlet-lib/src/components/VideoPlayer/Lounge.bs b/playlet-lib/src/components/VideoPlayer/Lounge.bs index 71ed3526..a32cdf14 100644 --- a/playlet-lib/src/components/VideoPlayer/Lounge.bs +++ b/playlet-lib/src/components/VideoPlayer/Lounge.bs @@ -16,8 +16,9 @@ namespace Lounge overrides[FIELD_VIDEO_ID] = videoId end if nowPlayingMsg = LoungeMessages.NowPlaying(m.top, overrides) - ' Sending playback speed to indicate that we will reset it to 1.0 when the content starts playing - playbackSpeedMsg = LoungeMessages.OnPlaybackSpeedChanged(playbackSpeed, true) + ' Reset the displayed speed to 1.0 on load. The content's live status (which decides VSP support) + ' isn't known yet here, so report only the speed, as the real receiver does for non-change updates. + playbackSpeedMsg = LoungeMessages.OnPlaybackSpeedChanged(playbackSpeed) m.loungeService.outgoingMessages = [nowPlayingMsg, loungeStateMsg, playbackSpeedMsg] end function