SpotifyAPI-NET icon indicating copy to clipboard operation
SpotifyAPI-NET copied to clipboard

Now SpotifyLocalAPI.RunSpotify() doesn't run on Windows 10.

Open StepIg opened this issue 8 years ago • 1 comments

Now SpotifyLocalAPI.RunSpotify() doesn't run on Windows 10. Anyone have this behavior too?

StepIg avatar Jul 28 '18 07:07 StepIg

All RunSpotify() does is find the spotify.exe and run it.

It doesn't work anymore because IsSpotifyRunning() can't retrieve the correct value. I recommend removing the LocalAPI from your progam entirely, you can use this function to start spotify instead:

using System.IO;

public void RunSpotify()
{
    Process[] pName = Process.GetProcessesByName("spotify");
    if (pName.Length != 0)
    {
        return; // A process with the name "spotify" is already running
    }
    if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"spotify\spotify.exe")))
        Process.Start(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"spotify\spotify.exe"));
}

Gruhlum avatar Jul 29 '18 15:07 Gruhlum