I built this to play live HLS streams as a screensaver on macOS. It supports both direct .m3u8 URLs and YouTube links (via yt-dlp extraction with caching). The interesting bits:

  • Cross-screen synchronization: All displays show the same frame of the video by syncing to a shared timestamp, making it feel like one continuous stream across monitors
  • Handles the unreliable macOS screensaver lifecycle (stopAnimation doesn’t always get called when dismissed, so I added system idle time detection to exit properly)
  • Caches yt-dlp extracted URLs with expiration timestamp parsing to avoid re-extraction on every launch
  • Includes stall detection and exponential backoff retry logic for flaky streams

Written in Swift using AVFoundation. The hardest part was dealing with macOS screensaver framework quirks - processes would stick around after dismissal until I added explicit idle detection using CGEventSource. MIT licensed. Would appreciate any feedback on the approach or edge cases I might have missed. Comments