summaryrefslogtreecommitdiff
path: root/internal/gui/audio_player.go
AgeCommit message (Collapse)Author
2026-04-06fix: track all GUI goroutines with WaitGroup and ctx.Done() (Go Mistake #62)Paul Buetow
Fire-and-forget goroutines in the tooltip setup, word-change handler, and audio playback could write to freed Fyne widgets after the window was closed. All four patterns are now fixed: - setupTooltips() and the secondary-toolbar tooltip block: replaced time.AfterFunc(500ms) with wg-tracked goroutines using select/ctx.Done(). - handleWordChange(): replaced time.AfterFunc(100ms) with the same pattern. - onWindowClosed(): added wordChangeTimer.Stop() to prevent its AfterFunc callback from firing after context cancellation. - AudioPlayer: added ctx context.Context field + SetContext(); the post-playback goroutine now guards fyne.Do with ctx.Err() == nil, and the auto-play AfterFunc is replaced with a ctx-aware goroutine. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-03fix: show full phonetic IPA in audio player barPaul Buetow
Two issues prevented the IPA from being fully displayed: 1. audio_player.go: switched the bottom bar from NewHBox to NewBorder so the phonetic label fills the centre column instead of being squeezed to its minimum width between the stop button and the status label. Also enabled TextWrapWord so very long IPA strings wrap rather than being clipped. 2. phonetic/fetcher.go: raised MaxOutputTokens from 50 to 200 so Gemini 2.5 Flash has enough budget to emit the full IPA bracket pair without truncation. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02task 004: replace time.Sleep goroutine synchronization with proper primitivesPaul Buetow
audio_player.go: use time.AfterFunc instead of goroutine+sleep for the 100ms auto-play delay — no goroutine is blocked waiting. app.go (setupUI, setupTooltips): replace goroutine+sleep with time.AfterFunc for both 500ms tooltip initialization delays. navigation.go: replace fixed 500ms sleep in the delete-cleanup goroutine with a ticker+select loop that polls hasActiveOperations(). The goroutine now proceeds as soon as all in-flight operations for the deleted word finish (or after a 5-second safety timeout), rather than waiting a fixed interval that may be too short or too long. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-02task 001: remove committed debug printf tracesPaul Buetow
2026-04-02Release v0.9.0v0.9.0Paul Buetow
2026-03-08fix(task-373): handle runtime cleanup errors in production pathsPaul Buetow
2026-01-21Fix: Auto-play only regenerated audio (front or back, not both) for bg-bg cardsv0.8.0Paul Buetow
- Removed duplicate fyne.KeyA handler that was triggering both front and back audio - Added SetAudioFileNoAutoPlay() method for controlled playback - Front audio (a key) now auto-plays only front audio - Back audio (A key) now auto-plays only back audio - Refactored startPlayback to use startPlaybackForFile for better control - Fixed icon reset when playback finishes for each audio type separately
2026-01-21improve: Space hotkey for back audio and consistent button iconsPaul Buetow
- Add Space key as primary hotkey to play back audio (bg-bg cards only) More intuitive than Shift+P for playing the second audio - Change back audio button icon from MediaSkipNextIcon to MediaPlayIcon Both front and back buttons now use the same play icon for consistency - Update hotkeys help dialog to document Space key Mark P/П as legacy (kept for backward compatibility) This makes the UI more consistent and the Space key is more natural for playing the back audio without using Shift.
2026-01-21improve: better audio player UI and debugging for bg-bg cardsPaul Buetow
- Add debug logging to navigation.go to diagnose audio file loading issues Prints paths being checked and whether files are found - Improve AudioPlayer UI for Bulgarian-Bulgarian cards: - Add labels showing 'Front' and 'Back' for bg-bg audio buttons - Labels only show when audio files are actually loaded - Better visual distinction between the two playable audios - Reorganized button layout with VBox for cleaner appearance - Track bg-bg state in AudioPlayer (isBgBg field) - Automatically set when back audio file is loaded - Used to determine when to show labels This makes it clearer that Bulgarian-Bulgarian cards have two independently playable audio outputs, and helps debug why audio isn't being loaded.
2025-07-21more on thisPaul Buetow
2025-07-21Release v0.7.0: Add auto-play feature and improve keyboard navigationv0.7.0Paul Buetow
New Features: - Added auto-play feature for audio with 'u'/'у' hotkey toggle - Auto-play is enabled by default on app startup - Automatically plays audio when new files are generated - Automatically plays audio when navigating between cards - Added Escape key support to unfocus all input fields - Works for Bulgarian word input - Works for English translation input - Works for image prompt multi-line input Improvements: - Increased default window size by 10% (800x700 → 880x770) - Fixed duplicate hotkey handling for 'u', 'h', and 'l' keys - Fixed tooltip initialization error by deferring audio player tooltips Bug Fixes: - Fixed Fyne threading errors in audio playback - Fixed tooltip layer initialization order issue - Removed duplicate keyboard shortcut handlers The auto-play feature enhances the learning experience by automatically playing pronunciation audio when cards are generated or when navigating through existing cards. Users can toggle this feature on/off at any time using the 'u' or 'у' hotkey.
2025-07-18feat: multiple improvements to GUI and codebasePaul Buetow
- Add random voice speed between 0.90-1.00 for more natural audio - Display voice and speed info in GUI audio player - Implement automatic retry loading for missing files (checks every 2 seconds) - Fix voice/speed info persistence during audio playback - Remove image caching functionality for cleaner codebase - Rename prompt.txt to image_prompt.txt for clarity - Fix GUI to recognize newly added cards during runtime (rescan on navigation) - Update README to reflect removed image cache These changes improve the user experience by making the audio more natural, providing better feedback about audio generation parameters, and ensuring the GUI stays synchronized with externally added cards. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-18fix: use timestamp+hash naming for directories in CLI to match GUIPaul Buetow
- Updated CLI code to use internal.GenerateCardID() for directory names - Changed file naming to match GUI: word.txt, translation.txt, audio.mp3, image.jpg/png - Created internal/utils.go with shared GenerateCardID and SanitizeFilename functions - Fixed all references to use the new naming system consistently - Ensures both CLI and GUI use the same directory and file naming convention 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-18feat: improve GUI usability with tooltips and reorganized layoutPaul Buetow
- Remove button captions in favor of icon-only buttons - Add comprehensive keyboard shortcuts dialog (File->Hotkeys) - Move toolbar with action buttons to top of window - Add hover tooltips to all buttons showing function and shortcut - Change export hotkey from 'E' to 'e' - Replace audio regenerate icon with more appropriate record icon - Add fyne-tooltip dependency for tooltip functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-18gui improvementsPaul Buetow
2025-07-16fix: update button labels to show lowercase hotkeys and improve export locationPaul Buetow
- Change all button labels to show lowercase letters (g, n, i, a, r, d, p) - Update delete confirmation dialog to show lowercase y/n - Set default export location to anki_cards directory - Add note about CSV needing to be in same directory as media files - Fix prompt generation to remove Bulgarian word reference 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-16feat: add custom image prompt support and keyboard shortcutsPaul Buetow
- Add text area next to image display for custom image generation prompts - Users can specify their own prompts or leave empty for auto-generation - Display the used prompt in the text area after generation - Load prompts from attribution files when navigating to existing cards - Add keyboard shortcuts for all GUI buttons: - G: Generate, N: New Word, I: Regenerate Image, A: Regenerate Audio - R: Regenerate All, D: Delete, P: Play audio - Left/Right arrows: Navigate between words - Y/N: Confirm/cancel delete dialog - Update UI layout with equal 50/50 split between image and prompt - Enable text wrapping in prompt text area - Add 25% chance to ask OpenAI for creative photo style suggestions - Fix concurrent processing to properly use custom prompts 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-16feat: add Fyne GUI mode with interactive flashcard managementPaul Buetow
- Add --gui flag to launch interactive GUI mode - Implement word navigation with prev/next buttons through existing cards - Add delete functionality to remove unwanted flashcards - Add fine-grained regeneration (image-only, audio-only, or both) - Implement audio playback using mpg123 on Linux - Auto-load first word on startup if cards exist - Save translation files for navigation persistence - Use DALL-E 2 with 512x512 images (half size) - Update audio speed to 0.9 (from 0.8) - Add comprehensive GUI documentation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>