fix: enable audio player seeking with HTTP Range request support
Problem
Audio seeking (scrubbing) in the Vime player was broken - clicking or dragging on the progress bar would reset playback to the beginning instead of seeking to the desired position.
Root Causes
-
preload="none"prevented the browser from loading audio metadata (duration), so the scrubber couldn't calculate seek positions - No HTTP Range request support - Both PHP's built-in dev server AND nginx Unit (used in the official Docker image) don't handle Range requests, which browsers require for seeking
Solution
- Changed
preload="none"→preload="metadata"so duration loads properly - Added [MediaController](cci:2://file:///Users/luke/Github/castopod/app/Controllers/MediaController.php:13:0-81:1) that serves audio files with proper HTTP Range headers (
206 Partial Content,Accept-Ranges: bytes) - Audio files now route through
/media-serve/endpoint which handles Range requests correctly - Fixed [play-episode-button.ts](cci:7://file:///Users/luke/Github/castopod/resources/js/\_modules/play-episode-button.ts:0:0-0:0) to properly update source element for Vime
Testing
- Play any episode
- Click/drag on the progress bar to seek
- Verify audio seeks to correct position instead of restarting
I can confirm i was getting the same behaviour as in this issue #545 (closed)\ and i have tested the fix on Brave, Firefox and Safari and it is working on all three.
Files Changed
- [app/Controllers/MediaController.php](cci:7://file:///Users/luke/Github/castopod/app/Controllers/MediaController.php:0:0-0:0) (new)
- [app/Config/Routes.php](cci:7://file:///Users/luke/Github/castopod/app/Config/Routes.php:0:0-0:0)
- [modules/Media/Helpers/url_helper.php](cci:7://file:///Users/luke/Github/castopod/modules/Media/Helpers/url_helper.php:0:0-0:0)
- [resources/js/audio-player.ts](cci:7://file:///Users/luke/Github/castopod/resources/js/audio-player.ts:0:0-0:0)
- [resources/js/_modules/play-episode-button.ts](cci:7://file:///Users/luke/Github/castopod/resources/js/\_modules/play-episode-button.ts:0:0-0:0)
- [themes/cp_app/embed.php](cci:7://file:///Users/luke/Github/castopod/themes/cp_app/embed.php:0:0-0:0)
- [app/Helpers/components_helper.php](cci:7://file:///Users/luke/Github/castopod/app/Helpers/components_helper.php:0:0-0:0)
Closes #545 (closed)