Skip to content

The truly free, open-source, local-first, cross-platform CapCut replacement. Scriptable through a JSON-RPC API & MCP.

fix(voiceover): Space and the playhead move a take and its picture together, and an iPhone records (#213)

Jareerba52b0c727ee
diff --git a/src/crates/concat/locales/ar.json b/src/crates/concat/locales/ar.json
index f177dcf1..6b4ab030 100644
--- a/src/crates/concat/locales/ar.json
+++ b/src/crates/concat/locales/ar.json
@@ -724,6 +724,7 @@
"voiceover.pause": "إيقاف مؤقت",
"voiceover.paused": "متوقف مؤقتًا",
"voiceover.permission": "يحتاج Concat إلى إذنك لاستخدام الميكروفون. اسمح به عند السؤال، ثم اضغط إعادة المحاولة.",
+ "voiceover.playheadHeld": "يبقى مؤشر التشغيل مع التسجيل. أوقف التسجيل لتحريكه.",
"voiceover.record": "تسجيل",
"voiceover.recording": "جارٍ التسجيل",
"voiceover.resume": "استئناف",
diff --git a/src/crates/concat/locales/bn.json b/src/crates/concat/locales/bn.json
index 082df4fe..8282f433 100644
--- a/src/crates/concat/locales/bn.json
+++ b/src/crates/concat/locales/bn.json
@@ -724,6 +724,7 @@
"voiceover.pause": "বিরতি",
"voiceover.paused": "বিরতিতে",
"voiceover.permission": "মাইক্রোফোন ব্যবহারের জন্য Concat-এর আপনার অনুমতি দরকার। জিজ্ঞাসা করা হলে অনুমতি দিন, তারপর আবার চেষ্টা করুন চাপুন।",
+ "voiceover.playheadHeld": "প্লেহেড টেকের সাথেই থাকে। এটি সরাতে টেকটি থামান।",
"voiceover.record": "রেকর্ড করুন",
"voiceover.recording": "রেকর্ড হচ্ছে",
"voiceover.resume": "চালিয়ে যান",
diff --git a/src/crates/concat/locales/de.json b/src/crates/concat/locales/de.json
index ee1e6d72..bb70ceb8 100644
--- a/src/crates/concat/locales/de.json
+++ b/src/crates/concat/locales/de.json
@@ -724,6 +724,7 @@
"voiceover.pause": "Pause",
"voiceover.paused": "Pausiert",
"voiceover.permission": "Concat braucht deine Erlaubnis, das Mikrofon zu verwenden. Erlaube es, wenn du gefragt wirst, und drücke dann Erneut versuchen.",
+ "voiceover.playheadHeld": "Der Abspielkopf bleibt bei der Aufnahme. Beende die Aufnahme, um ihn zu bewegen.",
"voiceover.record": "Aufnehmen",
"voiceover.recording": "Aufnahme läuft",
"voiceover.resume": "Fortsetzen",
diff --git a/src/crates/concat/locales/en.json b/src/crates/concat/locales/en.json
index b5199e46..32c8de8c 100644
--- a/src/crates/concat/locales/en.json
+++ b/src/crates/concat/locales/en.json
@@ -724,6 +724,7 @@
"voiceover.pause": "Pause",
"voiceover.paused": "Paused",
"voiceover.permission": "Concat needs your permission to use the microphone. Allow it when asked, then press Try again.",
+ "voiceover.playheadHeld": "The playhead stays with the take. Stop the take to move it.",
"voiceover.record": "Record",
"voiceover.recording": "Recording",
"voiceover.resume": "Resume",
diff --git a/src/crates/concat/locales/es.json b/src/crates/concat/locales/es.json
index 4c3d3ed2..91e10e44 100644
--- a/src/crates/concat/locales/es.json
+++ b/src/crates/concat/locales/es.json
@@ -724,6 +724,7 @@
"voiceover.pause": "Pausa",
"voiceover.paused": "En pausa",
"voiceover.permission": "Concat necesita tu permiso para usar el micrófono. Concédelo cuando se te pida y luego pulsa Reintentar.",
+ "voiceover.playheadHeld": "El cabezal se queda con la toma. Detén la toma para moverlo.",
"voiceover.record": "Grabar",
"voiceover.recording": "Grabando",
"voiceover.resume": "Reanudar",
diff --git a/src/crates/concat/locales/fa.json b/src/crates/concat/locales/fa.json
index ccb15a9a..49132b12 100644
--- a/src/crates/concat/locales/fa.json
+++ b/src/crates/concat/locales/fa.json
@@ -724,6 +724,7 @@
"voiceover.pause": "مکث",
"voiceover.paused": "متوقف",
"voiceover.permission": "Concat برای استفاده از میکروفون به اجازهٔ شما نیاز دارد. وقتی پرسیده شد اجازه دهید، سپس «تلاش دوباره» را بزنید.",
+ "voiceover.playheadHeld": "نشانگر پخش با برداشت می‌ماند. برای جابه‌جا کردنش، برداشت را متوقف کنید.",
"voiceover.record": "ضبط",
"voiceover.recording": "در حال ضبط",
"voiceover.resume": "ادامه",
diff --git a/src/crates/concat/locales/fr.json b/src/crates/concat/locales/fr.json
index 1fe188c5..86269c7a 100644
--- a/src/crates/concat/locales/fr.json
+++ b/src/crates/concat/locales/fr.json
@@ -724,6 +724,7 @@
"voiceover.pause": "Pause",
"voiceover.paused": "En pause",
"voiceover.permission": "Concat a besoin de votre autorisation pour utiliser le micro. Accordez-la quand elle vous est demandée, puis appuyez sur Réessayer.",
+ "voiceover.playheadHeld": "La tête de lecture reste avec la prise. Arrêtez la prise pour la déplacer.",
"voiceover.record": "Enregistrer",
"voiceover.recording": "Enregistrement",
"voiceover.resume": "Reprendre",
diff --git a/src/crates/concat/locales/he.json b/src/crates/concat/locales/he.json
index 6649d95e..c35eecfe 100644
--- a/src/crates/concat/locales/he.json
+++ b/src/crates/concat/locales/he.json
@@ -724,6 +724,7 @@
"voiceover.pause": "השהיה",
"voiceover.paused": "מושהה",
"voiceover.permission": "Concat צריך הרשאה להשתמש במיקרופון. יש לאשר כשתופיע הבקשה, ואז ללחוץ על ניסיון חוזר.",
+ "voiceover.playheadHeld": "סמן ההפעלה נשאר עם הטייק. עצרו את הטייק כדי להזיז אותו.",
"voiceover.record": "הקלטה",
"voiceover.recording": "מקליט",
"voiceover.resume": "המשך",
diff --git a/src/crates/concat/locales/hi.json b/src/crates/concat/locales/hi.json
index d9253183..e07843ba 100644
--- a/src/crates/concat/locales/hi.json
+++ b/src/crates/concat/locales/hi.json
@@ -724,6 +724,7 @@
"voiceover.pause": "विराम",
"voiceover.paused": "रुका हुआ",
"voiceover.permission": "Concat को माइक्रोफ़ोन इस्तेमाल करने के लिए आपकी अनुमति चाहिए। पूछे जाने पर अनुमति दें, फिर दोबारा कोशिश करें दबाएं।",
+ "voiceover.playheadHeld": "प्लेहेड टेक के साथ रहता है। इसे हिलाने के लिए टेक रोकें।",
"voiceover.record": "रिकॉर्ड करें",
"voiceover.recording": "रिकॉर्ड हो रहा है",
"voiceover.resume": "जारी रखें",
diff --git a/src/crates/concat/locales/hr.json b/src/crates/concat/locales/hr.json
index 6c06d4f1..1b76e4c4 100644
--- a/src/crates/concat/locales/hr.json
+++ b/src/crates/concat/locales/hr.json
@@ -724,6 +724,7 @@
"voiceover.pause": "Pauza",
"voiceover.paused": "Pauzirano",
"voiceover.permission": "Concat treba tvoje dopuštenje za korištenje mikrofona. Dopusti kad te pita, a zatim pritisni Pokušaj ponovno.",
+ "voiceover.playheadHeld": "Glava reprodukcije ostaje uz snimku. Zaustavite snimku da biste je pomaknuli.",
"voiceover.record": "Snimi",
"voiceover.recording": "Snimanje",
"voiceover.resume": "Nastavi",
diff --git a/src/crates/concat/locales/id.json b/src/crates/concat/locales/id.json
index 8757414d..1af10940 100644
--- a/src/crates/concat/locales/id.json
+++ b/src/crates/concat/locales/id.json
@@ -724,6 +724,7 @@
"voiceover.pause": "Jeda",
"voiceover.paused": "Dijeda",
"voiceover.permission": "Concat memerlukan izin Anda untuk menggunakan mikrofon. Izinkan saat diminta, lalu tekan Coba lagi.",
+ "voiceover.playheadHeld": "Playhead tetap mengikuti rekaman. Hentikan rekaman untuk memindahkannya.",
"voiceover.record": "Rekam",
"voiceover.recording": "Merekam",
"voiceover.resume": "Lanjutkan",
diff --git a/src/crates/concat/locales/it.json b/src/crates/concat/locales/it.json
index b73ecbaa..dfc436c5 100644
--- a/src/crates/concat/locales/it.json
+++ b/src/crates/concat/locales/it.json
@@ -724,6 +724,7 @@
"voiceover.pause": "Pausa",
"voiceover.paused": "In pausa",
"voiceover.permission": "Concat ha bisogno del tuo permesso per usare il microfono. Concedilo quando richiesto, poi premi Riprova.",
+ "voiceover.playheadHeld": "La testina resta con la ripresa. Interrompi la ripresa per spostarla.",
"voiceover.record": "Registra",
"voiceover.recording": "Registrazione in corso",
"voiceover.resume": "Riprendi",
diff --git a/src/crates/concat/locales/ja.json b/src/crates/concat/locales/ja.json
index 0b4d088c..6bfb837f 100644
--- a/src/crates/concat/locales/ja.json
+++ b/src/crates/concat/locales/ja.json
@@ -724,6 +724,7 @@
"voiceover.pause": "一時停止",
"voiceover.paused": "一時停止中",
"voiceover.permission": "Concat がマイクを使うには許可が必要です。確認されたら許可し、「再試行」を押してください。",
+ "voiceover.playheadHeld": "再生ヘッドはテイクに合わせて動きます。動かすにはテイクを停止してください。",
"voiceover.record": "録音",
"voiceover.recording": "録音中",
"voiceover.resume": "再開",
diff --git a/src/crates/concat/locales/ko.json b/src/crates/concat/locales/ko.json
index 6698d435..fd155892 100644
--- a/src/crates/concat/locales/ko.json
+++ b/src/crates/concat/locales/ko.json
@@ -724,6 +724,7 @@
"voiceover.pause": "일시 정지",
"voiceover.paused": "일시 정지됨",
"voiceover.permission": "Concat이 마이크를 사용하려면 권한이 필요합니다. 요청이 나타나면 허용한 뒤 다시 시도를 누르세요.",
+ "voiceover.playheadHeld": "재생 헤드는 테이크와 함께 움직입니다. 옮기려면 테이크를 중지하세요.",
"voiceover.record": "녹음",
"voiceover.recording": "녹음 중",
"voiceover.resume": "계속",
diff --git a/src/crates/concat/locales/nl.json b/src/crates/concat/locales/nl.json
index e2a51dc4..828935b3 100644
--- a/src/crates/concat/locales/nl.json
+++ b/src/crates/concat/locales/nl.json
@@ -724,6 +724,7 @@
"voiceover.pause": "Pauzeren",
"voiceover.paused": "Gepauzeerd",
"voiceover.permission": "Concat heeft je toestemming nodig om de microfoon te gebruiken. Sta het toe als erom gevraagd wordt en druk dan op Opnieuw proberen.",
+ "voiceover.playheadHeld": "De afspeelkop blijft bij de opname. Stop de opname om hem te verplaatsen.",
"voiceover.record": "Opnemen",
"voiceover.recording": "Bezig met opnemen",
"voiceover.resume": "Hervatten",
diff --git a/src/crates/concat/locales/pl.json b/src/crates/concat/locales/pl.json
index 44b36dfe..46280a10 100644
--- a/src/crates/concat/locales/pl.json
+++ b/src/crates/concat/locales/pl.json
@@ -724,6 +724,7 @@
"voiceover.pause": "Wstrzymaj",
"voiceover.paused": "Wstrzymano",
"voiceover.permission": "Concat potrzebuje twojej zgody na użycie mikrofonu. Zezwól, gdy pojawi się pytanie, a potem naciśnij Spróbuj ponownie.",
+ "voiceover.playheadHeld": "Głowica odtwarzania pozostaje przy nagraniu. Zatrzymaj nagranie, aby ją przesunąć.",
"voiceover.record": "Nagrywaj",
"voiceover.recording": "Nagrywanie",
"voiceover.resume": "Wznów",
diff --git a/src/crates/concat/locales/pt-BR.json b/src/crates/concat/locales/pt-BR.json
index a77bdea5..8202aa69 100644
--- a/src/crates/concat/locales/pt-BR.json
+++ b/src/crates/concat/locales/pt-BR.json
@@ -724,6 +724,7 @@
"voiceover.pause": "Pausar",
"voiceover.paused": "Pausado",
"voiceover.permission": "O Concat precisa da sua permissão para usar o microfone. Permita quando for solicitado e depois pressione Tentar de novo.",
+ "voiceover.playheadHeld": "O cursor de reprodução fica com a gravação. Pare a gravação para movê-lo.",
"voiceover.record": "Gravar",
"voiceover.recording": "Gravando",
"voiceover.resume": "Retomar",
diff --git a/src/crates/concat/locales/ru.json b/src/crates/concat/locales/ru.json
index d9d0a7ec..4cb55dba 100644
--- a/src/crates/concat/locales/ru.json
+++ b/src/crates/concat/locales/ru.json
@@ -724,6 +724,7 @@
"voiceover.pause": "Пауза",
"voiceover.paused": "На паузе",
"voiceover.permission": "Concat нужно ваше разрешение на использование микрофона. Разрешите его, когда появится запрос, затем нажмите «Повторить».",
+ "voiceover.playheadHeld": "Указатель воспроизведения следует за дублем. Остановите дубль, чтобы его сдвинуть.",
"voiceover.record": "Записать",
"voiceover.recording": "Идёт запись",
"voiceover.resume": "Продолжить",
diff --git a/src/crates/concat/locales/th.json b/src/crates/concat/locales/th.json
index a0d85bc6..849ecc81 100644
--- a/src/crates/concat/locales/th.json
+++ b/src/crates/concat/locales/th.json
@@ -724,6 +724,7 @@
"voiceover.pause": "หยุดชั่วคราว",
"voiceover.paused": "หยุดชั่วคราวอยู่",
"voiceover.permission": "Concat ต้องได้รับอนุญาตจากคุณเพื่อใช้ไมโครโฟน อนุญาตเมื่อระบบถาม แล้วกด ลองอีกครั้ง",
+ "voiceover.playheadHeld": "หัวเล่นอยู่กับเทค หยุดเทคก่อนเพื่อย้ายหัวเล่น",
"voiceover.record": "อัดเสียง",
"voiceover.recording": "กำลังอัดเสียง",
"voiceover.resume": "ทำต่อ",
diff --git a/src/crates/concat/locales/tr.json b/src/crates/concat/locales/tr.json
index 74ef50bc..ecc363d6 100644
--- a/src/crates/concat/locales/tr.json
+++ b/src/crates/concat/locales/tr.json
@@ -724,6 +724,7 @@
"voiceover.pause": "Duraklat",
"voiceover.paused": "Duraklatıldı",
"voiceover.permission": "Concat'in mikrofonu kullanmak için izninize ihtiyacı var. Sorulduğunda izin verin, ardından Yeniden dene'ye basın.",
+ "voiceover.playheadHeld": "Oynatma kafası çekimle birlikte kalır. Taşımak için çekimi durdurun.",
"voiceover.record": "Kayıt",
"voiceover.recording": "Kayıt yapılıyor",
"voiceover.resume": "Sürdür",
diff --git a/src/crates/concat/locales/uk.json b/src/crates/concat/locales/uk.json
index 68762215..4c135811 100644
--- a/src/crates/concat/locales/uk.json
+++ b/src/crates/concat/locales/uk.json
@@ -724,6 +724,7 @@
"voiceover.pause": "Пауза",
"voiceover.paused": "На паузі",
"voiceover.permission": "Concat потрібен ваш дозвіл на використання мікрофона. Дозвольте, коли з'явиться запит, а потім натисніть «Спробувати ще раз».",
+ "voiceover.playheadHeld": "Курсор відтворення лишається з дублем. Зупиніть дубль, щоб його посунути.",
"voiceover.record": "Записати",
"voiceover.recording": "Іде запис",
"voiceover.resume": "Продовжити",
diff --git a/src/crates/concat/locales/ur.json b/src/crates/concat/locales/ur.json
index c8b6ddd9..84d0465b 100644
--- a/src/crates/concat/locales/ur.json
+++ b/src/crates/concat/locales/ur.json
@@ -724,6 +724,7 @@
"voiceover.pause": "وقفہ",
"voiceover.paused": "وقفے پر",
"voiceover.permission": "Concat کو مائیکروفون استعمال کرنے کے لیے آپ کی اجازت درکار ہے۔ پوچھے جانے پر اجازت دیں، پھر دوبارہ کوشش کریں دبائیں۔",
+ "voiceover.playheadHeld": "پلے ہیڈ ٹیک کے ساتھ رہتا ہے۔ اسے ہلانے کے لیے ٹیک روکیں۔",
"voiceover.record": "ریکارڈ کریں",
"voiceover.recording": "ریکارڈنگ جاری ہے",
"voiceover.resume": "جاری رکھیں",
diff --git a/src/crates/concat/locales/vi.json b/src/crates/concat/locales/vi.json
index 260e2e37..85e931eb 100644
--- a/src/crates/concat/locales/vi.json
+++ b/src/crates/concat/locales/vi.json
@@ -724,6 +724,7 @@
"voiceover.pause": "Tạm dừng",
"voiceover.paused": "Đã tạm dừng",
"voiceover.permission": "Concat cần bạn cho phép sử dụng micrô. Hãy cho phép khi được hỏi, rồi nhấn Thử lại.",
+ "voiceover.playheadHeld": "Đầu phát đi theo bản thu. Dừng bản thu để di chuyển nó.",
"voiceover.record": "Ghi âm",
"voiceover.recording": "Đang ghi âm",
"voiceover.resume": "Tiếp tục",
diff --git a/src/crates/concat/locales/zh-Hans.json b/src/crates/concat/locales/zh-Hans.json
index 54dd0f91..6280f6b4 100644
--- a/src/crates/concat/locales/zh-Hans.json
+++ b/src/crates/concat/locales/zh-Hans.json
@@ -724,6 +724,7 @@
"voiceover.pause": "暂停",
"voiceover.paused": "已暂停",
"voiceover.permission": "Concat 需要你的许可才能使用麦克风。出现询问时请允许,然后按“重试”。",
+ "voiceover.playheadHeld": "播放头跟随当前录音。停止录音后才能移动它。",
"voiceover.record": "录制",
"voiceover.recording": "正在录制",
"voiceover.resume": "继续",
diff --git a/src/crates/concat/locales/zh-TW.json b/src/crates/concat/locales/zh-TW.json
index ac24385e..dd8d3b35 100644
--- a/src/crates/concat/locales/zh-TW.json
+++ b/src/crates/concat/locales/zh-TW.json
@@ -724,6 +724,7 @@
"voiceover.pause": "暫停",
"voiceover.paused": "已暫停",
"voiceover.permission": "Concat 需要你的許可才能使用麥克風。出現詢問時請允許,然後按「重試」。",
+ "voiceover.playheadHeld": "播放頭跟隨目前的錄音。停止錄音後才能移動它。",
"voiceover.record": "錄製",
"voiceover.recording": "正在錄製",
"voiceover.resume": "繼續",
diff --git a/src/crates/concat/src/ios.rs b/src/crates/concat/src/ios.rs
index 83c0bef7..676ba389 100644
--- a/src/crates/concat/src/ios.rs
+++ b/src/crates/concat/src/ios.rs
@@ -39,8 +39,35 @@ use crate::i18n::t;
#[link(name = "PhotosUI", kind = "framework")]
#[link(name = "Photos", kind = "framework")]
#[link(name = "UniformTypeIdentifiers", kind = "framework")]
+#[link(name = "AVFAudio", kind = "framework")]
unsafe extern "C" {}
+/// Sets the app's audio session to play and record at once, for a
+/// voiceover: the microphone open while the timeline plays. An iPhone's
+/// session plays only until told otherwise, and an input opened under it
+/// hears silence. The timeline goes on playing from the speaker rather
+/// than the earpiece the category would otherwise pick, and a Bluetooth
+/// headset's microphone may be the input. Asked each time the voiceover
+/// panel opens; setting what is already set costs nothing.
+pub fn record_alongside_playback() -> Result<(), String> {
+ /// AVAudioSessionCategoryOptions: DefaultToSpeaker | AllowBluetooth.
+ const OPTIONS: usize = 0x8 | 0x4;
+ let class = AnyClass::get(c"AVAudioSession").ok_or("this device has no audio session")?;
+ // SAFETY: `sharedInstance` takes nothing and returns the app's session;
+ // the two setters take what their selectors name and report through
+ // the trailing error, which `error: _` turns into the Result.
+ let session: Option<Retained<AnyObject>> = unsafe { msg_send![class, sharedInstance] };
+ let session = session.ok_or("this device has no audio session")?;
+ // The category constant's value is its own name.
+ let category = NSString::from_str("AVAudioSessionCategoryPlayAndRecord");
+ let set: Result<(), Retained<NSError>> =
+ unsafe { msg_send![&session, setCategory: &*category, withOptions: OPTIONS, error: _] };
+ set.map_err(|error| error.localizedDescription().to_string())?;
+ let active: Result<(), Retained<NSError>> =
+ unsafe { msg_send![&session, setActive: true, error: _] };
+ active.map_err(|error| error.localizedDescription().to_string())
+}
+
type Picked = Box<dyn FnOnce(Vec<PathBuf>) + Send>;
/// The pick in flight, waiting for a picker to answer.
@@ -220,7 +247,11 @@ fn choose(_mtm: MainThreadMarker) -> Result<(), &'static str> {
message: message,
preferredStyle: style
];
- let actions: [(String, isize, fn(MainThreadMarker) -> Result<(), &'static str>); 3] = [
+ let actions: [(
+ String,
+ isize,
+ fn(MainThreadMarker) -> Result<(), &'static str>,
+ ); 3] = [
(t("phone.fromPhotos"), 0, show_photos),
(t("phone.fromFiles"), 0, show_files),
(t("common.cancel"), 1, |_| Err("cancelled")),
@@ -250,7 +281,8 @@ fn choose(_mtm: MainThreadMarker) -> Result<(), &'static str> {
let _: () = msg_send![&alert, addAction: &*action];
}
let none: Option<&Block<dyn Fn()>> = None;
- let _: () = msg_send![&top, presentViewController: &*alert, animated: true, completion: none];
+ let _: () =
+ msg_send![&top, presentViewController: &*alert, animated: true, completion: none];
}
Ok(())
}
@@ -280,7 +312,8 @@ fn show_photos(mtm: MainThreadMarker) -> Result<(), &'static str> {
let picker: Retained<AnyObject> = msg_send![picker, initWithConfiguration: &*config];
let _: () = msg_send![&picker, setDelegate: &*delegate];
let none: Option<&Block<dyn Fn()>> = None;
- let _: () = msg_send![&top, presentViewController: &*picker, animated: true, completion: none];
+ let _: () =
+ msg_send![&top, presentViewController: &*picker, animated: true, completion: none];
}
Ok(())
}
@@ -302,14 +335,14 @@ fn show_files(mtm: MainThreadMarker) -> Result<(), &'static str> {
types.extend(kind);
}
let types = NSArray::from_retained_slice(&types);
- let picker: Allocated<AnyObject> =
- msg_send![class!(UIDocumentPickerViewController), alloc];
+ let picker: Allocated<AnyObject> = msg_send![class!(UIDocumentPickerViewController), alloc];
let picker: Retained<AnyObject> =
msg_send![picker, initForOpeningContentTypes: &*types, asCopy: true];
let _: () = msg_send![&picker, setAllowsMultipleSelection: true];
let _: () = msg_send![&picker, setDelegate: &*delegate];
let none: Option<&Block<dyn Fn()>> = None;
- let _: () = msg_send![&top, presentViewController: &*picker, animated: true, completion: none];
+ let _: () =
+ msg_send![&top, presentViewController: &*picker, animated: true, completion: none];
}
Ok(())
}
@@ -349,7 +382,11 @@ fn photos_picked(results: &NSArray<AnyObject>) {
let provider: Retained<AnyObject> = msg_send![&result, itemProvider];
let movie = NSString::from_str("public.movie");
let has_movie: bool = msg_send![&provider, hasItemConformingToTypeIdentifier: &*movie];
- let kind = if has_movie { movie } else { NSString::from_str("public.image") };
+ let kind = if has_movie {
+ movie
+ } else {
+ NSString::from_str("public.image")
+ };
let suggested: Option<Retained<NSString>> = msg_send![&provider, suggestedName];
let suggested = suggested.map(|name| name.to_string());
let tally = Arc::clone(&tally);
@@ -458,9 +495,8 @@ fn save_to_photos(path: &Path) -> Result<String, String> {
const ADD_ONLY: isize = 1;
// SAFETY: Photos' class methods, from any thread; the block is called
// once, from a queue of Photos'.
- let mut status: isize = unsafe {
- msg_send![class!(PHPhotoLibrary), authorizationStatusForAccessLevel: ADD_ONLY]
- };
+ let mut status: isize =
+ unsafe { msg_send![class!(PHPhotoLibrary), authorizationStatusForAccessLevel: ADD_ONLY] };
if status == 0 {
let (tx, rx) = std::sync::mpsc::channel();
let handler = RcBlock::new(move |answer: isize| {
diff --git a/src/crates/concat/src/lib.rs b/src/crates/concat/src/lib.rs
index cadd9f8e..2ffaa514 100644
--- a/src/crates/concat/src/lib.rs
+++ b/src/crates/concat/src/lib.rs
@@ -39,10 +39,10 @@ mod gpu;
mod grading;
mod host;
mod i18n;
-mod keymap;
/// The iPhone's pickers and its way to Photos; see the module.
#[cfg(target_os = "ios")]
mod ios;
+mod keymap;
mod meters;
mod platform;
/// What a phone's own crate installs before the window runs: the way to
diff --git a/src/crates/concat/src/meters.rs b/src/crates/concat/src/meters.rs
index ee978569..09e3467e 100644
--- a/src/crates/concat/src/meters.rs
+++ b/src/crates/concat/src/meters.rs
@@ -95,37 +95,38 @@ impl Studio {
// The peaks playback kept while nobody was reading them belong to
// some earlier moment; the first tick is to show this one.
let _ = self.host.playback.take_levels();
- self.meters.timer.start(slint::TimerMode::Repeated, TICK, || {
- crate::host::Shell::with(|shell, app| {
- let mut studio = shell.studio.borrow_mut();
- let rolling = studio.rolling();
- let shown = studio.meters_shown();
- let (left, right) = studio.host.playback.take_levels();
- let feed = &mut studio.meters;
- if !shown {
- // Put away mid-play: the bars drop to the floor now,
- // so they are not found standing where they were when
- // the meters are shown again, and the timer stops.
- feed.left = Side::default();
- feed.right = Side::default();
+ self.meters
+ .timer
+ .start(slint::TimerMode::Repeated, TICK, || {
+ crate::host::Shell::with(|shell, app| {
+ let mut studio = shell.studio.borrow_mut();
+ let rolling = studio.rolling();
+ let shown = studio.meters_shown();
+ let (left, right) = studio.host.playback.take_levels();
+ let feed = &mut studio.meters;
+ if !shown {
+ // Put away mid-play: the bars drop to the floor now,
+ // so they are not found standing where they were when
+ // the meters are shown again, and the timer stops.
+ feed.left = Side::default();
+ feed.right = Side::default();
+ feed.publish(&app);
+ feed.timer.stop();
+ return;
+ }
+ feed.left.tick(left, TICK.as_secs_f32());
+ feed.right.tick(right, TICK.as_secs_f32());
+ feed.clipped |= left >= 1.0 || right >= 1.0;
feed.publish(&app);
- feed.timer.stop();
- return;
- }
- feed.left.tick(left, TICK.as_secs_f32());
- feed.right.tick(right, TICK.as_secs_f32());
- feed.clipped |= left >= 1.0 || right >= 1.0;
- feed.publish(&app);
- if !rolling && feed.left.quiet() && feed.right.quiet() {
- feed.timer.stop();
- }
+ if !rolling && feed.left.quiet() && feed.right.quiet() {
+ feed.timer.stop();
+ }
+ });
});
- });
}
}
impl MeterFeed {
-
/// The clip light was clicked.
pub fn clear_clip(&mut self, app: &crate::ui::App) {
self.clipped = false;
diff --git a/src/crates/concat/src/panes/glide.rs b/src/crates/concat/src/panes/glide.rs
index 92c55f33..80be9b4c 100644
--- a/src/crates/concat/src/panes/glide.rs
+++ b/src/crates/concat/src/panes/glide.rs
@@ -153,7 +153,10 @@ impl Glide {
let to = Self::distance(self.speed, elapsed);
let moved = to - self.travelled;
self.travelled = to;
- (moved, Self::speed_at(self.speed, elapsed).abs() >= MIN_SPEED)
+ (
+ moved,
+ Self::speed_at(self.speed, elapsed).abs() >= MIN_SPEED,
+ )
}
}
@@ -282,7 +285,10 @@ mod tests {
}
// It covers nearly all of speed × TAU, and in about a second and
// a half: ln(3000 / 20) × TAU.
- assert!(total > 0.99 * 3000.0 * TAU && total <= 3000.0 * TAU, "{total}");
+ assert!(
+ total > 0.99 * 3000.0 * TAU && total <= 3000.0 * TAU,
+ "{total}"
+ );
assert!((90..=100).contains(&frames), "{frames}");
}
diff --git a/src/crates/concat/src/panes/timeline.rs b/src/crates/concat/src/panes/timeline.rs
index da8c1736..55c6b758 100644
--- a/src/crates/concat/src/panes/timeline.rs
+++ b/src/crates/concat/src/panes/timeline.rs
@@ -363,7 +363,11 @@ mod tests {
let mut view = pane(1000.0, 10.0, 0.1);
let before = (20.0 - view.scroll_left) / view.seconds_per_pixel;
pinch(&mut view, &[1.1, 1.3, 1.25, 2.0], 20.0);
- assert!((view.seconds_per_pixel - 0.05).abs() < 1e-6, "{}", view.seconds_per_pixel);
+ assert!(
+ (view.seconds_per_pixel - 0.05).abs() < 1e-6,
+ "{}",
+ view.seconds_per_pixel
+ );
let after = (20.0 - view.scroll_left) / view.seconds_per_pixel;
assert!((before - after).abs() < 1e-2, "{before} {after}");
// Spread past the closest zoom and back: held at the limit, and
diff --git a/src/crates/concat/src/panes/voiceover.rs b/src/crates/concat/src/panes/voiceover.rs
index cdd3c271..b927692d 100644
--- a/src/crates/concat/src/panes/voiceover.rs
+++ b/src/crates/concat/src/panes/voiceover.rs
@@ -125,6 +125,67 @@ enum Phase {
Paused,
}
+/// What a transport verb from anywhere but the panel - Space, the
+/// monitor's Play, the keymap's play, a click on the ruler - becomes while
+/// a take is under way. The picture and the take are one run: a verb that
+/// moved one without the other would leave the words out of step with
+/// the frames they were spoken to, so it moves both or neither.
+#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+enum Hold {
+ /// No take: the verb does what it always does.
+ Free,
+ /// Pause the take, and the picture with it.
+ Pause,
+ /// Carry the take on, and the picture with it.
+ Resume,
+ /// Call off the count-in.
+ CancelCount,
+ /// Not now: the playhead belongs to the take until it stops.
+ Refuse,
+}
+
+impl Phase {
+ /// Play or pause, toggled.
+ fn on_play(self) -> Hold {
+ match self {
+ Phase::Ready => Hold::Free,
+ Phase::Counting(_) => Hold::CancelCount,
+ Phase::Recording => Hold::Pause,
+ Phase::Paused => Hold::Resume,
+ }
+ }
+
+ /// The picture stopped from elsewhere - before a seek, a step, an
+ /// edit. At the end of the cut it stops by itself and the take records
+ /// on, with nothing more to be out of step with.
+ fn on_pause(self, at_end: bool) -> Hold {
+ match self {
+ Phase::Recording if !at_end => Hold::Pause,
+ _ => Hold::Free,
+ }
+ }
+
+ /// The playhead moved from elsewhere. A paused take resumes from where
+ /// it was held, so moving the playhead meanwhile would only be undone.
+ fn on_seek(self) -> Hold {
+ match self {
+ Phase::Recording | Phase::Paused => Hold::Refuse,
+ _ => Hold::Free,
+ }
+ }
+}
+
+impl Hold {
+ fn msg(self) -> Option<VoiceoverMsg> {
+ match self {
+ Hold::Free | Hold::Refuse => None,
+ Hold::Pause => Some(VoiceoverMsg::Pause),
+ Hold::Resume => Some(VoiceoverMsg::Resume),
+ Hold::CancelCount => Some(VoiceoverMsg::Stop),
+ }
+ }
+}
+
/// The take being recorded.
struct Running {
path: PathBuf,
@@ -173,6 +234,9 @@ pub struct VoiceoverPane {
meter: Option<slint::Timer>,
/// Beats the count-in.
countdown: Option<slint::Timer>,
+ /// A seek this take refused has been explained already: a drag along
+ /// the ruler asks dozens of times, and once is enough to be told.
+ told: bool,
}
impl VoiceoverPane {
@@ -182,6 +246,27 @@ impl VoiceoverPane {
self.phase != Phase::Ready
}
+ /// What Play becomes while a take is under way: the panel's own verb,
+ /// or None to play as usual. See [`Hold`].
+ pub fn on_play(&self) -> Option<VoiceoverMsg> {
+ self.phase.on_play().msg()
+ }
+
+ /// What stopping the picture becomes; `at_end` is the playhead at the
+ /// end of the cut.
+ pub fn on_pause(&self, at_end: bool) -> Option<VoiceoverMsg> {
+ self.phase.on_pause(at_end).msg()
+ }
+
+ /// Whether a seek is refused now, and whether to say why: Some(true)
+ /// the first time in a take, Some(false) after.
+ pub fn on_seek(&mut self) -> Option<bool> {
+ if self.phase.on_seek() != Hold::Refuse {
+ return None;
+ }
+ Some(!std::mem::replace(&mut self.told, true))
+ }
+
/// Applies one message.
pub fn update(&mut self, msg: VoiceoverMsg, studio: &mut Studio) {
match msg {
@@ -322,6 +407,16 @@ impl VoiceoverPane {
self.meter = None;
self.opened = None;
self.error = None;
+ // An iPhone records only with its audio session set to play and
+ // record together; left as it is, the microphone hands over
+ // silence. Set before the device opens, and a failure said
+ // plainly rather than a take of nothing.
+ #[cfg(target_os = "ios")]
+ if let Err(error) = crate::ios::record_alongside_playback() {
+ log::warn!("voiceover: the audio session would not record: {error}");
+ self.error = Some(tf("voiceover.failed", &[&error]));
+ return;
+ }
if !crate::platform::microphone_allowed() {
self.error = Some(t("voiceover.permission"));
return;
@@ -443,6 +538,7 @@ impl VoiceoverPane {
}
log::info!("voiceover: recording from {:.3}s", studio.playhead);
self.error = None;
+ self.told = false;
let start = f64::from(studio.playhead.max(0.0));
// The picture rolls under the words, without its sound unless the
// panel says otherwise. At the end of the cut there is nothing to
@@ -706,3 +802,48 @@ fn meter() -> slint::Timer {
);
timer
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn play_moves_the_take_and_the_picture_together() {
+ assert_eq!(Phase::Ready.on_play(), Hold::Free);
+ assert_eq!(Phase::Counting(2).on_play(), Hold::CancelCount);
+ assert_eq!(Phase::Recording.on_play(), Hold::Pause);
+ assert_eq!(Phase::Paused.on_play(), Hold::Resume);
+ }
+
+ #[test]
+ fn a_pause_from_elsewhere_pauses_the_take_too_until_the_cut_ends() {
+ assert_eq!(Phase::Recording.on_pause(false), Hold::Pause);
+ // At the end the picture has stopped by itself; the take records on.
+ assert_eq!(Phase::Recording.on_pause(true), Hold::Free);
+ assert_eq!(Phase::Paused.on_pause(false), Hold::Free);
+ assert_eq!(Phase::Ready.on_pause(false), Hold::Free);
+ assert_eq!(Phase::Counting(3).on_pause(false), Hold::Free);
+ }
+
+ #[test]
+ fn the_playhead_stays_put_while_a_take_holds_it() {
+ assert_eq!(Phase::Recording.on_seek(), Hold::Refuse);
+ assert_eq!(Phase::Paused.on_seek(), Hold::Refuse);
+ // A count-in has nothing recorded yet: the take starts wherever
+ // the playhead is when it ends.
+ assert_eq!(Phase::Counting(1).on_seek(), Hold::Free);
+ assert_eq!(Phase::Ready.on_seek(), Hold::Free);
+ }
+
+ #[test]
+ fn a_refused_seek_is_explained_once_a_take() {
+ let mut pane = VoiceoverPane::default();
+ assert_eq!(pane.on_seek(), None);
+ pane.phase = Phase::Recording;
+ assert_eq!(pane.on_seek(), Some(true));
+ assert_eq!(pane.on_seek(), Some(false));
+ pane.phase = Phase::Paused;
+ assert_eq!(pane.on_seek(), Some(false));
+ assert!(matches!(pane.on_play(), Some(VoiceoverMsg::Resume)));
+ }
+}
diff --git a/src/crates/concat/src/studio.rs b/src/crates/concat/src/studio.rs
index 6e334f41..0e9b46e4 100644
--- a/src/crates/concat/src/studio.rs
+++ b/src/crates/concat/src/studio.rs
@@ -2878,6 +2878,13 @@ impl Studio {
pub fn play_toggle(&mut self) {
self.stop_glide();
+ // A voiceover take owns the transport while it runs: Space, the
+ // monitor's button and the keymap's play pause or resume the take
+ // and the picture together, never the picture alone.
+ if let Some(msg) = self.voiceover.on_play() {
+ self.handle(crate::panes::Msg::Voiceover(msg));
+ return;
+ }
// The monitor's play button and Space play what it shows.
if self.source.is_some() {
self.source_toggle();
@@ -2956,6 +2963,14 @@ impl Studio {
}
pub fn pause(&mut self) {
+ // The picture stopped from anywhere - a seek, a step, an edit -
+ // stops the take with it. The panel's own pause comes through here
+ // with the pane taken out of the studio, so it is not sent back.
+ let at_end = self.playhead >= self.duration();
+ if let Some(msg) = self.voiceover.on_pause(at_end) {
+ self.handle(crate::panes::Msg::Voiceover(msg));
+ return;
+ }
if self.playing {
log::debug!("playback: paused at {:.3}s", self.playhead);
}
@@ -2974,6 +2989,15 @@ impl Studio {
/// lets it, which is the default, so the ruler can be clicked beyond the
/// last clip and something placed at the playhead there.
pub fn seek(&mut self, seconds: f32) {
+ // The playhead belongs to a voiceover take until it stops: moved
+ // under it, the words would land away from the frames they were
+ // spoken to.
+ if let Some(first) = self.voiceover.on_seek() {
+ if first {
+ self.notify(&t("voiceover.playheadHeld"), false);
+ }
+ return;
+ }
// The timeline was clicked: it has the monitor back.
self.close_source();
self.playhead = seconds.max(0.0);