Nothing Playing

This commit is contained in:
Hariharan Mudaliar 2026-03-03 12:25:02 +05:30
commit b46d88c79a
No known key found for this signature in database
GPG key ID: 025583EB0BE5640E
5 changed files with 118 additions and 60 deletions

View file

@ -17793,6 +17793,10 @@
}
}
},
"Nothing Playing" : {
"comment" : "A label displayed when there is nothing playing in the music player.",
"isCommentAutoGenerated" : true
},
"Notify before" : {
"comment" : "A label describing the slider that allows the user to set a reminder lead time.",
"isCommentAutoGenerated" : true,

View file

@ -111,7 +111,7 @@ struct LockScreenMusicPanel: View {
}
var body: some View {
if isActive {
if isActive && musicManager.hasActiveSession {
panelContent
} else {
Color.clear

View file

@ -45,6 +45,31 @@ struct MinimalisticMusicPlayerView: View {
private let skipMagnitude: CGFloat = 8
var body: some View {
if !musicManager.hasActiveSession {
// Nothing playing state
VStack(spacing: 0) {
Spacer(minLength: 0)
VStack(spacing: 8) {
Image(systemName: "music.note.slash")
.font(.system(size: 24, weight: .light))
.foregroundColor(.gray)
Text("Nothing Playing")
.font(.system(size: 12, weight: .medium))
.foregroundColor(.gray)
}
Spacer(minLength: 0)
timerCountdownSection
reminderList
}
.padding(.horizontal, 12)
.frame(maxWidth: .infinity)
.frame(height: calculateDynamicHeight())
.animation(.smooth(duration: 0.3), value: dynamicHeightSignature)
} else {
VStack(spacing: 0) {
// Header area with album art (matching DynamicIslandHeader height of 24pt)
GeometryReader { headerGeo in
@ -112,6 +137,7 @@ struct MinimalisticMusicPlayerView: View {
.frame(height: calculateDynamicHeight(), alignment: .top)
.animation(.smooth(duration: 0.3), value: dynamicHeightSignature)
}
}
// MARK: - TypingLyricView

View file

@ -521,9 +521,15 @@ struct NotchHomeView: View {
@ObservedObject var batteryModel = BatteryStatusViewModel.shared
@ObservedObject var coordinator = DynamicIslandViewCoordinator.shared
@ObservedObject private var extensionNotchExperienceManager = ExtensionNotchExperienceManager.shared
@ObservedObject private var musicManager = MusicManager.shared
@Default(.showStandardMediaControls) private var showStandardMediaControls
let albumArtNamespace: Namespace.ID
/// Whether the music player should actively display (enabled AND has real content).
private var shouldShowMusicPlayer: Bool {
showStandardMediaControls && musicManager.hasActiveSession
}
var body: some View {
Group {
if !coordinator.firstLaunch {
@ -546,14 +552,14 @@ struct NotchHomeView: View {
}
} else {
// Normal mode: Show full music player with optional calendar and webcam
if showStandardMediaControls {
if shouldShowMusicPlayer {
MusicPlayerView(albumArtNamespace: albumArtNamespace)
.frame(maxWidth: .infinity, alignment: .leading)
}
if Defaults[.showCalendar] {
Group {
if showStandardMediaControls {
if shouldShowMusicPlayer {
CalendarView()
} else {
StandaloneCalendarView()

View file

@ -78,6 +78,28 @@ class MusicManager: ObservableObject {
@Published var isPlaying = false
@Published var album: String = "Self Love"
@Published var isPlayerIdle: Bool = true
/// Whether there is an active music session with real metadata.
/// Returns `false` only when the metadata is still placeholder/fallback defaults
/// (i.e. nothing has been played since app launch, or the controller returned
/// unknown/not-playing placeholders). Paused music with real metadata is still
/// considered an active session.
private static let placeholderTitles: Set<String> = [
"i'm handsome", "unknown", "not playing"
]
private static let placeholderArtists: Set<String> = [
"me", "unknown"
]
var hasActiveSession: Bool {
if isPlaying { return true }
let trimmedTitle = songTitle.trimmingCharacters(in: .whitespacesAndNewlines).lowercased()
let trimmedArtist = artistName.trimmingCharacters(in: .whitespacesAndNewlines).lowercased()
let hasRealTitle = !trimmedTitle.isEmpty && !Self.placeholderTitles.contains(trimmedTitle)
let hasRealArtist = !trimmedArtist.isEmpty && !Self.placeholderArtists.contains(trimmedArtist)
return hasRealTitle || hasRealArtist
}
@Published var animations: DynamicIslandAnimations = .init()
@Published var avgColor: NSColor = .white
@Published var bundleIdentifier: String? = nil