From 113dd31275f934115d1b6fb689a82434149f9f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E7=BF=94=E5=AE=87?= Date: Mon, 20 Apr 2026 15:07:56 +0800 Subject: [PATCH] =?UTF-8?q?v2.0.5:=20adaptive=20polling=20=E2=80=94=20Appl?= =?UTF-8?q?e=20Music=200.8s=20when=20playing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit v2.0.4's 15s safety-net poll broke Apple Music latency because macOS 14+ Music.app doesn't reliably broadcast com.apple.Music.playerInfo, and MediaRemote is 15.4-gated. With no event source actually firing, 15s between polls = 15s track-change lag. Poll interval is now computed from stickySource + isPlaying: - Apple Music playing → 0.8s (no reliable event source) - Chrome playing → 1.2s (no event source, web audio too) - Spotify playing → 3.0s (playerInfo broadcast is fast, poll is just backup) - MediaRemote playing → 3.0s (MR notifications cover it) - Idle / nothing playing → 10.0s (NSWorkspace launch observer will wake us instantly) rearmPoll() is called after every stickySource change + after the optimistic isPlaying flip in togglePlayPause, so the cadence adapts within a single RunLoop tick. Cheap: if the new interval equals the current one within 0.01s, skip the Timer re-alloc. Co-Authored-By: Claude Opus 4.7 (1M context) --- Info.plist | 4 +-- Sources/NowPlayingState.swift | 59 ++++++++++++++++++++++++++++------- 2 files changed, 50 insertions(+), 13 deletions(-) diff --git a/Info.plist b/Info.plist index a8f2804..65092c3 100644 --- a/Info.plist +++ b/Info.plist @@ -15,9 +15,9 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 2.0.4 + 2.0.5 CFBundleVersion - 6 + 7 NSPrincipalClass MusicPlugin.MusicPlugin