Bug
FLAC audiobooks take a long time to start playing compared to other formats like MP3 or M4B. The delay happens every time you hit play, not just on first import.
What's going on
In PlayerManager.swift, the AVPlayerItem is created with the default initializer:
self.playerItem = AVPlayerItem(asset: asset)
This defaults to automaticallyLoadedAssetKeys: ["duration"], so the player item won't become ready until AVFoundation has fully resolved the asset's duration.
For MP3/M4B this is basically instant since duration is right in the file header. FLAC is a different story — AVFoundation's decoder doesn't seem to use FLAC's built-in seek tables, so it has to scan deeper into the file to figure out precise timing. That, combined with AVURLAssetPreferPreciseDurationAndTimingKey: true (which is needed for accurate seeking), means there's a noticeable wait before anything plays.
Suggested fix
self.playerItem = AVPlayerItem(asset: asset, automaticallyLoadedAssetKeys: [])
This keeps precise timing enabled on the asset so seeking stays accurate, but it stops blocking readiness on the duration key. The app already stores its own duration from import time, so the UI and playback logic don't actually depend on the asset's duration property.
Would apply to both the main player (line 261) and the watch player.
Apple talks about this approach in WWDC 2022 "Create a more responsive media app" — basically, don't block readiness on keys you don't need right away.
Would need testing
- Does playback actually start faster on a real device?
- Does seeking still land correctly once the background load finishes?
- Any issues with bookmarks, sleep timer, or sync positions?
Happy to put together a PR if this sounds right.
Bug
FLAC audiobooks take a long time to start playing compared to other formats like MP3 or M4B. The delay happens every time you hit play, not just on first import.
What's going on
In
PlayerManager.swift, theAVPlayerItemis created with the default initializer:This defaults to
automaticallyLoadedAssetKeys: ["duration"], so the player item won't become ready until AVFoundation has fully resolved the asset's duration.For MP3/M4B this is basically instant since duration is right in the file header. FLAC is a different story — AVFoundation's decoder doesn't seem to use FLAC's built-in seek tables, so it has to scan deeper into the file to figure out precise timing. That, combined with
AVURLAssetPreferPreciseDurationAndTimingKey: true(which is needed for accurate seeking), means there's a noticeable wait before anything plays.Suggested fix
This keeps precise timing enabled on the asset so seeking stays accurate, but it stops blocking readiness on the duration key. The app already stores its own duration from import time, so the UI and playback logic don't actually depend on the asset's duration property.
Would apply to both the main player (line 261) and the watch player.
Apple talks about this approach in WWDC 2022 "Create a more responsive media app" — basically, don't block readiness on keys you don't need right away.
Would need testing
Happy to put together a PR if this sounds right.