return; //We need to call Connect before fetching infos, this will handle Auth stuff
StatusResponse status = _spotify.GetStatus(); //status contains infos
}
</code></pre>
<h2id="configuration">Configuration</h2>
<p>Different spotify versions often require different configuration. Some versions run their web-helper on port <code>4371</code>, others on <code>4381</code>. Also, some use <code>https</code>, and others use <code>http</code>. You can use <code>SpotifyLocalAPIConfig</code> to configure the API:</p>
<pre><codeclass="cs">_spotify = new SpotifyLocalAPI(new SpotifyLocalAPIConfig
<p>Some Anti-Virus Software blocks the response from spotify due wrong headers.
Currently, it's confirmed for AVG's LinkScanner and Bitdefender.
Adding <code>http://SpotifyAPI.spotilocal.com:4380</code> to the URL-Exceptions seems to fix it for most users.
More infos can be found <ahref="https://github.com/JohnnyCrazy/SpotifyAPI-NET/issues/51">here</a></p>
<h2id="client-status">Client Status</h2>
<p>Calling <code>_spotify.GetStatus()</code> after connecting returns the following <code>StatusResponse</code>:</p>
<pre><code>public int Version { get; set; }
public string ClientVersion { get; set; }
public bool Playing { get; set; }
public bool Shuffle { get; set; }
public bool Repeat { get; set; }
public bool PlayEnabled { get; set; }
public bool PrevEnabled { get; set; }
public bool NextEnabled { get; set; }
public Track Track { get; set; }
public double PlayingPosition { get; set; }
public int ServerTime { get; set; }
public double Volume { get; set; }
public bool Online { get; set; }
public bool Running { get; set; }
</code></pre>
<p>Most of the properties are self-explanatory, some notes:</p>
<ul>
<li><code>Shuffle</code> and <code>Repeat</code> currently always return <code>false</code></li>
</ul>
<h2id="current-track">Current Track</h2>
<p>The current Track can be fetched via <code>_spotify.GetStatus().Track</code> and contains following properties/methods:</p>
<ul>
<li><code>TrackResource</code> - <code>SpotifyResource</code> which contains Track <code>Name</code> and <code>Uri</code></li>
<li><code>AlbumResource</code> - <code>SpotifyResource</code> which contains Album <code>Name</code> and <code>Uri</code></li>
<li><code>ArtistResource</code> - <code>SpotifyResource</code> which contains Artist <code>Name</code> and <code>Uri</code> (Only the main artist will be listed)</li>
<li><code>IsAd()</code> will check whether the current track is an AD</li>
<li>Various methods for getting the album art:</li>
<p>To receive events, make sure you listen for them <code>_spotify.ListenForEvents = true;</code><br/>
You can set a <code>SynchronizingObject</code>, then the events will be called on the specific context</p>
<p>Following events can be overriden:</p>
<ul>
<li><code>OnPlayStateChange</code> - triggers when the player changes from <code>play</code> to <code>pause</code> and vice versa</li>
<li><code>OnTrackChange</code> - triggers when a new track will be played</li>
<li><code>OnTrackTimeChange</code> - triggers when a track is playing and track-time changes</li>
<li><code>OnVolumeChange</code> - triggeres when the internal volume of spotify changes</li>
</ul>
<h2id="methods">Methods</h2>
<p>Furthermore, following methods are available:</p>
<ul>
<li><code>void Mute()</code> - will mute the Spotify client via WindowsAPI</li>
<li><code>void UnMute()</code> - will unmute the Spotify client via WindowsAPI</li>
<li><code>bool IsSpotifyMuted()</code> - will return wether the Spotify client is muted</li>
<li><code>void SetSpotifyVolume(float volume = 100)</code> - sets the windows volume of spotify (0 - 100)</li>
<li><code>float GetSpotifyVolume()</code> - returns the windows volume of spotify (0 - 100)</li>
<li><code>void Pause()</code> - will pause spotify's playback</li>
<li><code>void Play()</code> - will resume spotify's playback</li>
<li><code>void PlayURL(string uri, string context = "")</code> - will play a spotify URI (track/album/playlist) in the specifc context (can be a album/playlist URI)</li>
<li><code>void Skip()</code> - will skip the track via an emulated media key</li>
<li><code>void Previous()</code> - will play the previous track via an emulated media key</li>
<li><code>bool IsSpotifyRunning()</code> - returns true if a spotify client instance is running, false if not</li>
<li><code>bool IsSpotifyWebHelperRunning()</code> - returns true if a spotify web-helper instance is running, false if not</li>
<li><code>void RunSpotify()</code> - will attempt to start a Spotify instance</li>
<li><code>void RunSpotifyWebHelper()</code> - will attempt to start a Spotify web-helper instance</li>