From 1240bda2b205c7a55c1e49c000b9efcc3c5e9aa0 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Tue, 16 Dec 2025 11:47:00 -0600 Subject: [PATCH] crap forgot to add slide_actions --- src/core/slide_actions.rs | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/core/slide_actions.rs diff --git a/src/core/slide_actions.rs b/src/core/slide_actions.rs new file mode 100644 index 0000000..4e7130f --- /dev/null +++ b/src/core/slide_actions.rs @@ -0,0 +1,41 @@ +use miette::{IntoDiagnostic, Result}; +use std::sync::Arc; +use tracing::warn; + +use obws::{Client, responses::scenes::Scene}; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub(crate) enum ObsAction { + Scene { scene: Scene }, + StartStream, + StopStream, +} + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +pub(crate) enum Action { + Obs { action: ObsAction }, + Other, +} + +impl ObsAction { + pub async fn run(&self, client: Arc) -> Result<()> { + match self { + ObsAction::Scene { scene } => { + warn!(?scene, "Changing obs scenes"); + client + .scenes() + .set_current_program_scene(&scene.id) + .await + .into_diagnostic()?; + } + ObsAction::StartStream => { + client.streaming().start().await.into_diagnostic()? + } + ObsAction::StopStream => { + client.streaming().stop().await.into_diagnostic()? + } + } + Ok(()) + } +}