Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
delay emitting current recording changed + audio in separate thread
Brendan Allan4ea2a3a4ed73
diff --git a/apps/desktop/src-tauri/src/audio.rs b/apps/desktop/src-tauri/src/audio.rsindex d92cf91b5..f7841bd7a 100644--- a/apps/desktop/src-tauri/src/audio.rs+++ b/apps/desktop/src-tauri/src/audio.rs@@ -396,17 +396,19 @@ pub async fn start_capturing(// controller// }-fn play_audio<const N: usize>(bytes: &'static [u8; N]) {+fn play_audio(bytes: &'static [u8]) {use rodio::{Decoder, OutputStream, Sink};use std::io::Cursor;- if let Ok((_, stream)) = OutputStream::try_default() {- let file = Cursor::new(bytes);- let source = Decoder::new(file).unwrap();- let sink = Sink::try_new(&stream).unwrap();- sink.append(source);- sink.sleep_until_end();- }+ std::thread::spawn(move || {+ if let Ok((_, stream)) = OutputStream::try_default() {+ let file = Cursor::new(bytes);+ let source = Decoder::new(file).unwrap();+ let sink = Sink::try_new(&stream).unwrap();+ sink.append(source);+ sink.sleep_until_end();+ }+ });}pub enum AppSounds {@@ -417,12 +419,12 @@ pub enum AppSounds {impl AppSounds {pub fn play(self) {- match self {+ play_audio(match self {AppSounds::StartRecording => {- play_audio(include_bytes!("../sounds/start-recording.ogg"))+ include_bytes!("../sounds/start-recording.ogg")}- AppSounds::StopRecording => play_audio(include_bytes!("../sounds/stop-recording.ogg")),- AppSounds::Screenshot => play_audio(include_bytes!("../sounds/screenshot.ogg")),- }+ AppSounds::StopRecording => include_bytes!("../sounds/stop-recording.ogg"),+ AppSounds::Screenshot => include_bytes!("../sounds/screenshot.ogg"),+ })}}diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex 6f653b75d..1c33b16d2 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -156,10 +156,6 @@ impl App {pub fn clear_current_recording(&mut self) -> Option<InProgressRecording> {self.close_occluder_window();- CurrentRecordingChanged(JsonValue::new(&None))- .emit(&self.handle)- .ok();-self.current_recording.take()}@@ -479,6 +475,10 @@ async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Result<AppSounds::StopRecording.play();+ CurrentRecordingChanged(JsonValue::new(&None))+ .emit(&app)+ .ok();+Ok(())}@@ -2000,6 +2000,10 @@ pub fn run() {{let mut app_state = state.write().await;if let Some(mut recording) = app_state.clear_current_recording() {+ CurrentRecordingChanged(JsonValue::new(&None))+ .emit(&app_handle)+ .ok();+println!("Stopping and discarding current recording");recording.stop_and_discard();}diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rsindex 1ed30cd08..950ddc7bc 100644--- a/apps/desktop/src-tauri/src/recording.rs+++ b/apps/desktop/src-tauri/src/recording.rs@@ -13,6 +13,7 @@ use std::{sync::{Arc, Mutex},};use std::{path::PathBuf, time::Duration};+use tauri::AppHandle;use tokio::sync::watch;use objc::rc::autoreleasepool;diff --git a/packages/ui-solid/src/auto-imports.d.ts b/packages/ui-solid/src/auto-imports.d.tsindex 3d2b7b708..304b9a1d5 100644--- a/packages/ui-solid/src/auto-imports.d.ts+++ b/packages/ui-solid/src/auto-imports.d.ts@@ -3,7 +3,6 @@// @ts-nocheck// noinspection JSUnusedGlobalSymbols// Generated by unplugin-auto-import-// biome-ignore lint: disableexport {}declare global {const IconCapArrows: typeof import('~icons/cap/arrows.jsx')['default']