示例#1
0
        public static void WriteCurrentSong(SpotifyPlayerContext currentTrack)
        {
            if (currentTrack?.Item?.Album == null || currentTrack.Item.Artists.IsNullOrEmpty())
            {
                WriteYellow("Nothing is playing right now.");
                return;
            }

            WriteYellow($"Now Playing: {currentTrack.Item?.Name} - {currentTrack.Item?.Album?.Name} - {currentTrack.Item?.Artists.FirstOrDefault()?.Name}");
        }
示例#2
0
        private async Task <SpotifyPlayerContext> WaitForNextTrack(SpotifyPlayerContext previousTrack)
        {
            var currentlyPlayingTrack = (SpotifyPlayerContext)null;
            var retries = 0;

            while (++retries < 10 &&
                   (currentlyPlayingTrack = await GetPlayerContext()).Item.Id == previousTrack.Item.Id &&
                   currentlyPlayingTrack.ProgressInMs >= previousTrack.ProgressInMs)
            {
                Thread.Sleep(150);
            }
            return(currentlyPlayingTrack);
        }