Skip to content

Commit 26b5f80

Browse files
ferdinhJohnnyCrazy
authored andcommitted
add api to check if spotify is installed (#193)
1 parent a70bc5f commit 26b5f80

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

SpotifyAPI/Local/SpotifyLocalAPI.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,31 @@ public static Boolean IsSpotifyWebHelperRunning()
302302
return Process.GetProcessesByName("spotifywebhelper").Length >= 1;
303303
}
304304

305+
/// <summary>
306+
/// Determines whether [spotify is installed].
307+
/// </summary>
308+
/// <returns>
309+
/// <c>true</c> if [spotify is installed]; otherwise, <c>false</c>.
310+
/// </returns>
311+
public static bool IsSpotifyInstalled()
312+
{
313+
bool isInstalled = false;
314+
315+
// Checks if UWP Spotify is installed.
316+
string uwpSpotifyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Packages\SpotifyAB.SpotifyMusic_zpdnekdrzrea0");
317+
318+
isInstalled = Directory.Exists(uwpSpotifyPath);
319+
320+
// If UWP Spotify is not installed, try look for desktop version
321+
if (!isInstalled)
322+
{
323+
string desktopSpotifyPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Spotify\Spotify.exe");
324+
isInstalled = File.Exists(desktopSpotifyPath);
325+
}
326+
327+
return isInstalled;
328+
}
329+
305330
/// <summary>
306331
/// Runs Spotify
307332
/// </summary>

0 commit comments

Comments
 (0)