protected override void OnSpotifyStateChanged(object sender, SpotifyStateChangedEventArgs e)
        {
            base.OnSpotifyStateChanged(sender, e);

            if (e.NewState == SpotifyState.PlayingAdvertisement)
            {
                Logger.AdSkipper.LogInfo("Starting to skip ad");
                Task.Run(() => KillAndRestartSpotifyAsync());
            }
        }
        protected override void OnSpotifyStateChanged(object sender, SpotifyStateChangedEventArgs eventArgs)
        {
            base.OnSpotifyStateChanged(sender, eventArgs);

            var oldState = eventArgs.PreviousState;
            var newState = eventArgs.NewState;

            if (newState == SpotifyState.StartingUp || newState == SpotifyState.ShuttingDown)
            {
                return;
            }

            // we skip here as no audio session is present and muting would fail.
            if (oldState == SpotifyState.StartingUp && newState == SpotifyState.Paused)
            {
                return;
            }

            if (AggressiveMuting)
            {
                muter.SetMute(newState != SpotifyState.PlayingSong);
                return;
            }

            if (!WaitForAudioFade || oldState != SpotifyState.PlayingAdvertisement)
            {
                muter.SetMute(mute: newState == SpotifyState.PlayingAdvertisement);
                return;
            }

            if (newState == SpotifyState.PlayingAdvertisement)
            {
                muter.Mute();
                return;
            }

            Task.Run(async() => {
                await Task.Delay(600).ConfigureAwait(false);
                muter.Unmute();
            });
        }
Exemplo n.º 3
0
 protected virtual void OnSpotifyStateChanged(object sender, SpotifyStateChangedEventArgs e)
 {
 }
Exemplo n.º 4
0
 /// <summary>
 /// OnSpotifyStateChanged is called whenever the current state of spotify changes.
 /// </summary>
 /// <param name="eventArgs"></param>
 protected virtual void OnSpotifyStateChanged(SpotifyStateChangedEventArgs eventArgs) {
     Logger.LogInfo($"SpotifyHook: Spotify is in {eventArgs.NewState} state.");
     SpotifyStateChanged?.Invoke(this, eventArgs);
 }