private string _lastTrackFullName; //local files handling
        private void UpdateTrackInfo(IPlaybackResponse playbackState)
        {
            if (playbackState == null)
            {
                return;
            }

            PlayingTrackControl.Update(playbackState);

            string gameName = _gameProcess.CurrentProcess?.WindowName ?? "";

            UserSettingsBlock.Update(_userContext.LastAccount, gameName);

            if (_lastTrackFullName == playbackState.FullName)
            {
                return;
            }

            BackgroundCover.Update(playbackState.CoverUrl);
            _configWriter.RewriteKeyBinding(playbackState);

            _lastTrackFullName = playbackState.FullName;

            if (UserSettingsBlock.AutosendCheck.IsToggled && _gameProcess.IsValid)
            {
                _keySender.SendSystemInput(UserSettingsBlock.CurrentVirtualKey);
            }
        }
        public void Update(IPlaybackResponse resp)
        {
            var currentTrack = (PlayingTrackModel)Resources["currentTrack"];

            currentTrack.UpdateProperties(resp);
            Progress.Update(GetProgess(resp.Progress, resp.Duration));
        }
Beispiel #3
0
        private static void onPlaybackStateUpdate(IPlaybackResponse resp)
        {
            if (resp == null)
            {
                Console.Clear();
                Console.WriteLine("Nothing is playing!");
                return;
            }

            Console.Clear();
            Console.WriteLine($"{resp.FullName} ({resp.ProgressMinutes}:{resp.ProgressSeconds:00})");
            Console.WriteLine("Current account: " + steamContext.LastAccount);
            Console.WriteLine("Current key: " + currentKey);

            if (resp.Id != lastTrackId)
            {
                if (process.IsValid)
                {
                    keySender.SendSystemInput(currentKeyVirtual);
                }

                lastTrackId = resp.Id;
                configWriter.RewriteKeyBinding(resp);
            }
        }
Beispiel #4
0
 public void UpdateProperties(IPlaybackResponse resp)
 {
     FormattedArtists = resp.FormattedArtists;
     Name             = resp.Name;
     ProgressMinutes  = resp.ProgressMinutes;
     ProgressSeconds  = resp.ProgressSeconds;
     DurationMinutes  = resp.DurationMinutes;
     DurationSeconds  = resp.DurationSeconds;
 }
Beispiel #5
0
        public void RewriteKeyBinding(IPlaybackResponse currentTrack)
        {
            int indexOfAudioCfg = this.writePath.IndexOf(@"\audio.cfg");

            Directory.CreateDirectory(this.writePath.Remove(indexOfAudioCfg));

            if (!File.Exists(this.writePath))
            {
                File.CreateText(this.writePath).Dispose();
            }

            string strForWriting = string.Format(this.writeConfigText, currentTrack.FullName);

            this.RewriteKeyBinding(strForWriting);
        }
 /// <summary>
 /// Add User Playback Handler
 /// </summary>
 /// <param name="client">Spotify Sdk Client</param>
 /// <param name="response">Playback Response</param>
 public static async void AddUserPlaybackHandler(
     this ISpotifySdkClient client,
     IPlaybackResponse response) =>
 await client.AddUserPlaybackAsync(
     response.PlaybackStartType,
     response.Id);