diff --git a/SpotifyAPI/Local/SpotifyLocalAPI.cs b/SpotifyAPI/Local/SpotifyLocalAPI.cs index d5707b85..245ca1c2 100644 --- a/SpotifyAPI/Local/SpotifyLocalAPI.cs +++ b/SpotifyAPI/Local/SpotifyLocalAPI.cs @@ -302,6 +302,31 @@ namespace SpotifyAPI.Local return Process.GetProcessesByName("spotifywebhelper").Length >= 1; } + /// + /// Determines whether [spotify is installed]. + /// + /// + /// true if [spotify is installed]; otherwise, false. + /// + public static bool IsSpotifyInstalled() + { + bool isInstalled = false; + + // Checks if UWP Spotify is installed. + string uwpSpotifyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Packages\SpotifyAB.SpotifyMusic_zpdnekdrzrea0"); + + isInstalled = Directory.Exists(uwpSpotifyPath); + + // If UWP Spotify is not installed, try look for desktop version + if (!isInstalled) + { + string desktopSpotifyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Spotify\Spotify.exe"); + isInstalled = File.Exists(desktopSpotifyPath); + } + + return isInstalled; + } + /// /// Runs Spotify ///