diff options
| -rw-r--r-- | desktop/island/Obs.qml | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/desktop/island/Obs.qml b/desktop/island/Obs.qml index c57cf7d..9b8ba06 100644 --- a/desktop/island/Obs.qml +++ b/desktop/island/Obs.qml @@ -27,6 +27,10 @@ Singleton { property bool connected: false property bool recording: false property bool paused: false + // RecordStateChanged is authoritative once one has arrived; the 1s poll + // then only carries the clock, so a response from just before the pause + // cannot put the panel back into "not recording". + property bool stateFromEvents: false property real duration: 0 property var scenes: [] property string scene: "" @@ -84,8 +88,8 @@ Singleton { WebSocket { id: sock onStatusChanged: { - if (status === WebSocket.Open) { root.wasOpen = true; return; } - if (status === WebSocket.Connecting) return; + if (sock.status === WebSocket.Open) { root.wasOpen = true; return; } + if (sock.status === WebSocket.Connecting) return; // QML's WebSocket hides the close code, so a wrong password // (4009) and OBS quitting look the same. Say it once per run. if (root.wasOpen && !root.connected && !root.warned) { @@ -103,6 +107,7 @@ Singleton { function reset() { connected = false; wasOpen = false; recording = false; paused = false; duration = 0; + stateFromEvents = false; scenes = []; scene = ""; camId = -1; camOn = false; camW = 0; camH = 0; desktopAudio = ""; desktopMuted = false; @@ -184,6 +189,7 @@ Singleton { function event(type, d) { switch (type) { case "RecordStateChanged": + stateFromEvents = true; // obs-websocket reports outputActive false while PAUSED, so a // paused take must still count as recording or the panel offers // Record and a click stops it. @@ -218,9 +224,12 @@ Singleton { const r = d.responseData || {}; switch (d.requestType) { case "GetRecordStatus": - paused = r.outputPaused; - recording = r.outputActive || r.outputPaused; duration = r.outputDuration; + // Seed the state on connect; after that the events own it. + if (!root.stateFromEvents) { + paused = r.outputPaused; + recording = r.outputActive || r.outputPaused; + } break; case "GetSceneList": // obs-websocket lists scenes bottom-up; reversed is OBS's own order. |
