Skip to content

Commit ff1e3c1

Browse files
committed
feat(deeplink): add pause, resume, and device switching actions (#1540)
1 parent 2c49c7d commit ff1e3c1

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

apps/desktop/src-tauri/src/deeplink_actions.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ pub enum DeepLinkAction {
3232
OpenSettings {
3333
page: Option<String>,
3434
},
35+
PauseRecording,
36+
ResumeRecording,
37+
SwitchMicrophone {
38+
mic_label: Option<String>,
39+
},
40+
SwitchCamera {
41+
camera: Option<DeviceOrModelID>,
42+
},
3543
}
3644

3745
pub fn handle(app_handle: &AppHandle, urls: Vec<Url>) {
@@ -152,6 +160,41 @@ impl DeepLinkAction {
152160
DeepLinkAction::OpenSettings { page } => {
153161
crate::show_window(app.clone(), ShowCapWindow::Settings { page }).await
154162
}
163+
DeepLinkAction::PauseRecording => {
164+
crate::recording::pause_recording(app.clone(), app.state()).await
165+
}
166+
DeepLinkAction::ResumeRecording => {
167+
crate::recording::resume_recording(app.clone(), app.state()).await
168+
}
169+
DeepLinkAction::SwitchMicrophone { mic_label } => {
170+
if let Some(ref label) = mic_label {
171+
let available_mics = cap_recording::feeds::microphone::MicrophoneFeed::list();
172+
if !available_mics.contains_key(label) {
173+
return Err(format!("Microphone with label \"{}\" not found", label));
174+
}
175+
}
176+
177+
let state = app.state::<ArcLock<App>>();
178+
crate::set_mic_input(state, mic_label).await
179+
}
180+
DeepLinkAction::SwitchCamera { camera } => {
181+
if let Some(ref id) = camera {
182+
let cameras: Vec<_> = cap_camera::list_cameras().collect();
183+
let exists = cameras.iter().any(|info| match id {
184+
DeviceOrModelID::DeviceID(device_id) => info.device_id() == device_id,
185+
DeviceOrModelID::ModelID(model_id) => {
186+
info.model_id().is_some_and(|existing| existing == model_id)
187+
}
188+
});
189+
190+
if !exists {
191+
return Err(format!("Camera with ID \"{:?}\" not found", id));
192+
}
193+
}
194+
195+
let state = app.state::<ArcLock<App>>();
196+
crate::set_camera_input(app.clone(), state, camera).await
197+
}
155198
}
156199
}
157200
}

0 commit comments

Comments
 (0)