Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 private static void session_OnPlayTokenLost(object sender, EventArgs e)
 {
     if (_currentTrack != null)
     {
         _session.PlayerUnload();
         _currentTrack = null;
     }
 }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
 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();
     }
 }