Skip to content

Commit

Permalink
Fix Music bug in revealSong, improvements to canRevealSong logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangarelick committed May 15, 2024
1 parent 78a4f3b commit 90b6129
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion SoundSeer/SoundSeerViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,18 @@ class SoundSeerViewModel: ObservableObject {
}

var canRevealSong: Bool {
player != nil
if player != nil, let playbackState = playbackState {
return playbackState == .paused || playbackState == .playing
}
return false
}

func revealSong() {
guard let player = player else { return }
switch player {
case .music:
MusicApplication.app?.currentTrack?.reveal()
MusicApplication.app?.activate() // Reveal does not bring the app to the foreground
case .spotify:
if let uriString = SpotifyApplication.app?.currentTrack?.spotifyUrl, let uri = URL(string: uriString) {
NSWorkspace.shared.open(uri)
Expand Down

0 comments on commit 90b6129

Please sign in to comment.