From 64daaa3371addb898204ee6a86a370e2859612f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E7=BF=94=E5=AE=87?= Date: Sun, 19 Apr 2026 02:27:21 +0800 Subject: [PATCH] v2.0.0: full rewrite with multi-source NowPlaying MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the v1.0.0 shell (MediaRemote-only, non-functional on macOS 15.4+) with a layered design that handles four playback sources with sticky source priority routing: NowPlayingState (orchestrator, @MainActor, 3s poll + notifications) ├─ MediaRemote (private framework, dlopen) ├─ Spotify AppleScript (desktop) ├─ Apple Music AppleScript (desktop) └─ Chrome JS injection (YouTube / SoundCloud / web music) UI: - Large album art with color-extracted gradient background - Title / artist / album + source badge - Draggable seek bar with hover-grow affordance - Prev / Play·Pause (56pt lime button) / Next controls - Header slot: 20x20 icon + 3-bar pseudo-spectrum that pulses while playing - Bi-lingual (zh / en), follows host appLanguage Graceful degradation: - Host < v2.1.7 → upgrade banner (NSAppleEventsUsageDescription required) - QQ Music / NetEase / Kugou detected → "desktop unsupported, try web version" - Empty state with hint to play something in supported apps Build layout: Sources/ root (MioPlugin.swift contract + MusicPlugin principal) Sources/sources/ data sources Sources/ui/ SwiftUI views Sources/support/ ChineseAppDetector / HostVersionCheck / Localization build.sh now recursively finds .swift under Sources/. Breaking-ish: plugin id ("music-player") and bundle ID preserved. Users on v1.0.0 can upgrade in place via the plugin store. Requires: MioIsland host >= v2.1.7 for full functionality. Co-Authored-By: Claude Opus 4.7 (1M context) --- Info.plist | 4 +- README.md | 181 ++++++-- Sources/MusicHeaderButton.swift | 54 --- Sources/MusicPlayerView.swift | 116 ----- Sources/MusicPlugin.swift | 43 +- Sources/NowPlayingBridge.swift | 129 ------ Sources/NowPlayingState.swift | 475 ++++++++++++++++++++ Sources/sources/AppleMusicAppleScript.swift | 90 ++++ Sources/sources/ChromeWebSource.swift | 305 +++++++++++++ Sources/sources/MediaRemoteSource.swift | 193 ++++++++ Sources/sources/SpotifyAppleScript.swift | 136 ++++++ Sources/support/ChineseAppDetector.swift | 64 +++ Sources/support/HostVersionCheck.swift | 92 ++++ Sources/support/Localization.swift | 118 +++++ Sources/ui/AlbumArtColorExtractor.swift | 134 ++++++ Sources/ui/ExpandedView.swift | 376 ++++++++++++++++ Sources/ui/HeaderSlotView.swift | 121 +++++ Sources/ui/SeekBar.swift | 94 ++++ build.sh | 6 +- 19 files changed, 2379 insertions(+), 352 deletions(-) delete mode 100644 Sources/MusicHeaderButton.swift delete mode 100644 Sources/MusicPlayerView.swift delete mode 100644 Sources/NowPlayingBridge.swift create mode 100644 Sources/NowPlayingState.swift create mode 100644 Sources/sources/AppleMusicAppleScript.swift create mode 100644 Sources/sources/ChromeWebSource.swift create mode 100644 Sources/sources/MediaRemoteSource.swift create mode 100644 Sources/sources/SpotifyAppleScript.swift create mode 100644 Sources/support/ChineseAppDetector.swift create mode 100644 Sources/support/HostVersionCheck.swift create mode 100644 Sources/support/Localization.swift create mode 100644 Sources/ui/AlbumArtColorExtractor.swift create mode 100644 Sources/ui/ExpandedView.swift create mode 100644 Sources/ui/HeaderSlotView.swift create mode 100644 Sources/ui/SeekBar.swift diff --git a/Info.plist b/Info.plist index 2591f5c..c89da35 100644 --- a/Info.plist +++ b/Info.plist @@ -15,9 +15,9 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 1.0.0 + 2.0.0 CFBundleVersion - 1 + 2 NSPrincipalClass MusicPlugin.MusicPlugin diff --git a/README.md b/README.md index bb864e1..233748b 100644 --- a/README.md +++ b/README.md @@ -1,76 +1,175 @@ # Music Player Plugin for MioIsland -A native plugin that brings real-time music playback information to your MioIsland Notch bar. See what's currently playing across any music app on your Mac without leaving your workflow. +> **v2.0.0 — full rewrite.** Real Now Playing info from Spotify, Apple Music, +> Google Chrome (YouTube / SoundCloud / 网页版音乐), with playback controls, +> draggable seek bar, album art color tint, and a pseudo-spectrum in the header +> icon. Replaces the v1.0.0 shell that only wired up MediaRemote. ## Features -- Displays the currently playing track, artist, and album from any macOS music app (Apple Music, Spotify, etc.) -- Reads system NowPlaying metadata — no need to configure individual apps -- Lightweight native `.bundle` plugin with minimal resource usage -- Smooth animated UI that matches the MioIsland design language -- Appears as a header icon button in the Notch bar +- **Multi-source playback tracking** with sticky source priority: + - MediaRemote (private framework, any app that registers with `MPNowPlayingInfoCenter`) + - Spotify desktop (AppleScript) + - Apple Music desktop (AppleScript) + - Google Chrome tabs (JavaScript injection into `