feat: implement audio seeking with arrow keys via ffplay restart

Seek now works by restarting ffplay with -ss offset instead of the
broken player.seek() stub. MoveLeft/MoveRight added as aliases for
SeekBackward/SeekForward to fix HashMap non-deterministic iteration
order causing Left arrow to resolve to MoveLeft instead of SeekBackward.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Mikhail Kilin
2026-02-09 18:51:45 +03:00
parent 8a467b6418
commit 6d08300daa
3 changed files with 60 additions and 44 deletions

View File

@@ -65,16 +65,16 @@ Feature-gated (`images`), 2-tier архитектура:
- **VoiceCache**: LRU кэш OGG файлов в `~/.cache/tele-tui/voice/` (max 100 MB)
- **Типы**: `VoiceInfo`, `VoiceDownloadState`, `PlaybackState`, `PlaybackStatus`
- **TDLib интеграция**: `download_voice_note()`, конвертация `MessageVoiceNote`
- **Хоткеи**: Space (play/pause), ←/→ (seek ±5s)
- **Хоткеи**: Space (play/pause), ←/→ (seek ±5s via ffplay restart с `-ss`)
- **Автостоп**: при навигации на другое сообщение воспроизведение останавливается
**Доделано в этой сессии:**
- **Ticker**: `last_playback_tick` в App + обновление position в event loop каждые 16ms
- **VoiceCache интеграция**: проверка кэша перед загрузкой, кэширование после download
- **Ticker**: `last_playback_tick` в App + обновление position в event loop (1 FPS redraw)
- **VoiceCache**: проверка кэша перед загрузкой, кэширование после download
- **AudioConfig**: `[audio]` секция в config.toml (cache_size_mb, auto_download_voice)
**Не реализовано (optional):**
- UI индикаторы в сообщениях (🎤, progress bar, waveform) — начаты в diff, не подключены
- **UI**: progress bar (━●─) + waveform (▁▂▃▄▅▆▇█) + иконки статуса в `message_bubble.rs`
- **Race condition fixes**: `starting` flag + pid ownership guard в потоках AudioPlayer
- **Seek**: `resume_from()` перезапускает ffplay с `-ss` offset; MoveLeft/MoveRight как alias для SeekBackward/SeekForward
- **Resume with rewind**: пауза→продолжение откатывает на 1 секунду назад
- **Graceful shutdown**: `stop_playback()` + Drop impl для AudioPlayer
### Ключевая архитектура