public static void Print(TextWriter writer, Spotify.Session session, Spotify.Track track) { TimeSpan duration = track.Duration; if (session != null) { writer.WriteLine(" " + track.IsStarred(session)); } writer.WriteLine("Track {0} [{1}] has {2} artist(s), {3}% popularity", track.Name, track.Duration, track.Artists.Count, track.Popularity); if (track.Disc != 0) { writer.WriteLine("\t {0} on dics {1}", track.Index, track.Disc); } foreach (Spotify.Artist artist in track.Artists) { writer.WriteLine("\t Artist: {0}", artist.Name); } }
private static void session_OnPlayTokenLost(object sender, EventArgs e) { if (_currentTrack != null) { _session.PlayerUnload(); _currentTrack = null; } }
private static void TryJukeboxStart() { if (_jukeboxList == null) { return; } IList <Spotify.Track> tracks = _jukeboxList.Tracks; if (tracks.Count == 0) { Console.WriteLine("jukebox: No more tracks in playlist. Waiting"); return; } if (_trackIndex >= tracks.Count) { Console.WriteLine("jukebox: Not more tracks in playlist. Waiting"); return; } Spotify.Track track = tracks[_trackIndex]; if (_currentTrack != null && !_currentTrack.IsClone(track)) { _session.PlayerUnload(); _audioSink.Stop(); _audioProvider.ClearBuffer(); _currentTrack = null; } if (track.Error != Spotify.Error.Ok) { return; } if (_currentTrack != null && _currentTrack.IsClone(track)) { return; } Console.WriteLine("jukebox: Now playing \"{0}\"...", track.Name); _session.PlayerLoad(track); _session.PlayerPlay(true); _audioSink.Play(); _currentTrack = track; }
private static void playlist_OnRenamed(object sender, EventArgs e) { Spotify.Playlist playlist = (Spotify.Playlist)sender; if (playlist.Name.Equals(_listname)) { _jukeboxList = playlist; _trackIndex = 0; TryJukeboxStart(); } else { Console.WriteLine("jukebox: current playlist renamed to: {0}", playlist.Name); _jukeboxList = null; _currentTrack = null; _session.PlayerUnload(); } }