aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--deckit/modules/obs.py26
-rw-r--r--static/deck.css4
-rw-r--r--static/modules/obs.js25
-rw-r--r--tests/test_obs.py29
4 files changed, 73 insertions, 11 deletions
diff --git a/deckit/modules/obs.py b/deckit/modules/obs.py
index 491f45f..b50b0af 100644
--- a/deckit/modules/obs.py
+++ b/deckit/modules/obs.py
@@ -70,9 +70,10 @@ def make(cfg: dict) -> Module:
scenes = req("GetSceneList")
rec = req("GetRecordStatus")
stream = req("GetStreamStatus")
- trans = req("GetCurrentSceneTransition")
- kinds = req("GetTransitionKindList").get("transitionKinds", [])
+ # Names, not kinds: SetCurrentSceneTransition takes "Fade", not "fade_transition".
+ trans = req("GetSceneTransitionList")
current = scenes.get("currentProgramSceneName")
+ studio = req("GetStudioModeEnabled").get("studioModeEnabled", False)
sources = []
if current:
for item in req("GetSceneItemList", {"sceneName": current}).get("sceneItems", []):
@@ -96,11 +97,14 @@ def make(cfg: dict) -> Module:
"connected": True,
"scenes": [s["sceneName"] for s in scenes.get("scenes", [])],
"currentScene": current,
+ "studio": studio,
+ "previewScene": scenes.get("currentPreviewSceneName") if studio else None,
"recording": rec.get("outputActive", False),
+ "paused": rec.get("outputPaused", False),
"recordingTime": rec.get("outputDuration", 0) / 1000,
"streaming": stream.get("outputActive", False),
- "transitions": kinds,
- "transition": trans.get("transitionName"),
+ "transitions": [t["transitionName"] for t in trans.get("transitions", [])],
+ "transition": trans.get("currentSceneTransitionName"),
"sources": sources,
"inputs": inputs,
}
@@ -109,7 +113,11 @@ def make(cfg: dict) -> Module:
name = body.get("scene")
if not isinstance(name, str) or not name:
raise ModuleError("scene required")
- req("SetCurrentProgramScene", {"sceneName": name})
+ # In Studio Mode a tap cues the scene; Transition sends it live.
+ if req("GetStudioModeEnabled").get("studioModeEnabled"):
+ req("SetCurrentPreviewScene", {"sceneName": name})
+ else:
+ req("SetCurrentProgramScene", {"sceneName": name})
def flag(body):
on = body.get("on")
@@ -120,6 +128,12 @@ def make(cfg: dict) -> Module:
def record(body):
req("StartRecord" if flag(body) else "StopRecord")
+ def studio(body):
+ req("SetStudioModeEnabled", {"studioModeEnabled": flag(body)})
+
+ def pause(body):
+ req("PauseRecord" if flag(body) else "ResumeRecord")
+
def stream(body):
req("StartStream" if flag(body) else "StopStream")
@@ -149,7 +163,7 @@ def make(cfg: dict) -> Module:
return Module(
name="obs", title="OBS", state=state,
- actions={"scene": scene, "record": record, "stream": stream, "mute": mute,
+ actions={"scene": scene, "record": record, "pause": pause, "studio": studio, "stream": stream, "mute": mute,
"volume": volume, "transition": transition, "trigger": trigger,
"source": source, "properties": properties},
start=lambda: threading.Thread(target=connect_loop, daemon=True).start(),
diff --git a/static/deck.css b/static/deck.css
index 8a318ef..ee8bc37 100644
--- a/static/deck.css
+++ b/static/deck.css
@@ -415,6 +415,8 @@ select {
.deck-btn .ico { width: 28px; height: 28px; }
.deck-btn .num { font-size: 1.429rem; }
.deck-btn.rec.on { background: var(--udt-red); border-color: var(--udt-red); color: var(--udt-crust); }
+.deck-btn.pause.on { background: var(--udt-yellow); border-color: var(--udt-yellow); color: var(--udt-crust); }
+.deck-btn.studio.on { background: var(--udt-accent); border-color: var(--udt-accent); color: var(--udt-crust); }
.deck-btn.live.on { background: var(--udt-green); border-color: var(--udt-green); color: var(--udt-crust); }
.deck-btn:active { background: var(--udt-surface1); }
@@ -462,6 +464,8 @@ select {
border-color: var(--udt-accent);
color: var(--udt-crust);
}
+/* Studio Mode: the scene waiting in Preview for the Transition button */
+.tile.cue { border: 2px dashed var(--udt-accent); color: var(--udt-text); }
.mixer { display: flex; flex-direction: column; gap: 10px; }
.chan { display: flex; align-items: center; gap: 10px; }
diff --git a/static/modules/obs.js b/static/modules/obs.js
index 5005ffc..6842522 100644
--- a/static/modules/obs.js
+++ b/static/modules/obs.js
@@ -27,6 +27,9 @@ const ICONS = {
muted: '<path d="M11 5 6 9H2v6h4l5 4V5Z"/><path d="m22 9-6 6"/><path d="m16 9 6 6"/>',
eye: '<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z"/><circle cx="12" cy="12" r="3"/>',
eyeOff: '<path d="m2 2 20 20"/><path d="M6.7 6.7C4.1 8.4 2 12 2 12s3.5 7 10 7c1.7 0 3.2-.4 4.5-1"/><path d="M9.9 4.2C10.6 4.1 11.3 4 12 4c6.5 0 10 7 10 7a18 18 0 0 1-2.2 3.2"/>',
+ pause: '<path d="M9 5v14"/><path d="M15 5v14"/>',
+ resume: '<path d="m7 4 13 8-13 8V4Z"/>',
+ studio: '<rect x="2" y="5" width="9" height="12" rx="1"/><rect x="13" y="5" width="9" height="12" rx="1"/><path d="M8 21h8"/>',
transition: '<path d="M2 7h14l-3-3"/><path d="M22 17H8l3 3"/>',
};
@@ -63,18 +66,29 @@ function renderTransport(box, s) {
const rec = bigButton("rec", "record", s.recording ? "Stop" : "Record", s.recording,
s.recording ? clock(s.recordingTime) : "");
rec.onclick = () => post("record", { on: !s.recording });
+ box.append(rec);
+ if (s.recording) {
+ const pause = bigButton("pause", s.paused ? "resume" : "pause", s.paused ? "Resume" : "Pause", s.paused);
+ pause.onclick = () => post("pause", { on: !s.paused });
+ box.append(pause);
+ }
const stream = bigButton("live", "stream", s.streaming ? "Stop stream" : "Stream", s.streaming);
stream.onclick = () => post("stream", { on: !s.streaming });
- const trigger = bigButton("trig", "transition", "Transition", false);
- trigger.onclick = () => post("trigger");
- box.append(rec, stream, trigger);
+ const studio = bigButton("studio", "studio", "Studio", s.studio);
+ studio.onclick = () => post("studio", { on: !s.studio });
+ box.append(stream, studio);
+ if (s.studio) {
+ const trigger = bigButton("trig", "transition", "Transition", false);
+ trigger.onclick = () => post("trigger");
+ box.append(trigger);
+ }
}
function renderTiles(box, items, onPick, onLong) {
box.textContent = "";
for (const item of items) {
const b = document.createElement("button");
- b.className = `tile${item.on ? " on" : ""}`;
+ b.className = `tile${item.on ? " on" : ""}${item.cue ? " cue" : ""}`;
b.innerHTML = `${item.icon ? icon(item.icon) : ""}<span></span>${onLong ? '<i class="gear">⚙</i>' : ""}`;
b.querySelector("span").textContent = item.label;
let timer = null;
@@ -170,7 +184,8 @@ export default {
}
renderTransport(transport, state);
renderTiles(el.querySelector(".scenes"),
- (state.scenes ?? []).map((name) => ({ label: name, icon: "scene", on: name === state.currentScene })),
+ (state.scenes ?? []).map((name) => ({ label: name, icon: "scene", on: name === state.currentScene,
+ cue: state.studio && name === state.previewScene && name !== state.currentScene })),
(item) => post("scene", { scene: item.label }));
if (!el._pressing) {
renderTiles(el.querySelector(".sources"),
diff --git a/tests/test_obs.py b/tests/test_obs.py
index 48a0274..0c9a1a6 100644
--- a/tests/test_obs.py
+++ b/tests/test_obs.py
@@ -49,6 +49,35 @@ class Actions(unittest.TestCase):
self.m.actions["record"]({"on": False})
self.assertEqual(Fake.last[0], "StopRecord")
+ def test_scene_cues_preview_in_studio_mode(self):
+ class Studio(Fake):
+ def request(self, kind, data=None):
+ if kind == "GetStudioModeEnabled":
+ return {"studioModeEnabled": True}
+ return super().request(kind, data)
+ obs.make({"client": Studio()}).actions["scene"]({"scene": "Live"})
+ self.assertEqual(Fake.last, ("SetCurrentPreviewScene", {"sceneName": "Live"}))
+ self.m.actions["studio"]({"on": True})
+ self.assertEqual(Fake.last, ("SetStudioModeEnabled", {"studioModeEnabled": True}))
+
+ def test_pause_and_resume(self):
+ self.m.actions["pause"]({"on": True})
+ self.assertEqual(Fake.last[0], "PauseRecord")
+ self.m.actions["pause"]({"on": False})
+ self.assertEqual(Fake.last[0], "ResumeRecord")
+
+ def test_transitions_are_names(self):
+ class Obs(Fake):
+ def request(self, kind, data=None):
+ if kind == "GetSceneTransitionList":
+ return {"currentSceneTransitionName": "Fade",
+ "transitions": [{"transitionName": "Cut", "transitionKind": "cut_transition"},
+ {"transitionName": "Fade", "transitionKind": "fade_transition"}]}
+ return {}
+ st = obs.make({"client": Obs()}).state()
+ self.assertEqual(st["transitions"], ["Cut", "Fade"])
+ self.assertEqual(st["transition"], "Fade")
+
def test_mute_and_source(self):
self.m.actions["mute"]({"input": "Mic", "muted": True})
self.assertEqual(Fake.last[0], "SetInputMute")