public static void SendAction(SpotifyAction a) { // bah. Because control cannot fall through cases we need to special case volume if (SettingsXml.Current.ChangeSpotifyVolumeOnly) { if (a == SpotifyAction.VolumeUp) { VolumeHelper.IncrementVolume("Spotify"); return; } else if (a == SpotifyAction.VolumeDown) { VolumeHelper.DecrementVolume("Spotify"); return; } else if (a == SpotifyAction.Mute) { VolumeHelper.ToggleApplicationMute("Spotify"); return; } } switch (a) { case SpotifyAction.CopyTrackInfo: case SpotifyAction.ShowToast: //Nothing break; case SpotifyAction.ShowSpotify: ShowSpotify(); break; } }
public static void controlSpotify(SpotifyAction sa) { BringToForeground("Spotify"); switch (sa) { case SpotifyAction.Next: SendKeys.SendWait("^({RIGHT})"); break; case SpotifyAction.Previous: SendKeys.SendWait("^({LEFT})"); break; case SpotifyAction.VolumeUp: SendKeys.SendWait("^({UP})"); break; case SpotifyAction.VolumeDown: SendKeys.SendWait("^({DOWN})"); break; case SpotifyAction.PlayPause: SendKeys.SendWait(" "); break; } }
/// <summary> /// Sends a command to Spotify /// </summary> /// <param name="action">The command to send</param> internal bool Command(SpotifyAction action) { if (!IsInitalized) { return(false); } Win32.SendMessage(_spotify, Win32.Constants.WM_APPCOMMAND, IntPtr.Zero, new IntPtr((long)action)); return(true); }
public static void SendAction(SpotifyAction a) { if (!Spotify.IsAvailable()) { return; } switch (a) { case SpotifyAction.CopyTrackInfo: case SpotifyAction.ShowSpotify: ShowSpotify(); break; default: Win32.SendMessage(GetSpotify(), Win32.Constants.WM_APPCOMMAND, IntPtr.Zero, new IntPtr((long)a)); break; } }
public void DisplayAction(SpotifyAction action, Song trackBeforeAction) { //Anything that changes track doesn't need to be handled since //that will be handled in the timer event. const string VOLUME_UP_TEXT = "Volume ++"; const string VOLUME_DOWN_TEXT = "Volume --"; const string MUTE_ON_OFF_TEXT = "Mute On/Off"; const string NOTHINGS_PLAYING = "Nothing's playing"; const string PAUSED_TEXT = "Paused"; const string STOPPED_TEXT = "Stopped"; const string SETTINGS_TEXT = "Settings saved"; if (!Spotify.IsRunning() && action != SpotifyAction.SettingsSaved) { toastIcon = DEFAULT_ICON; Title1.Text = "Spotify not available!"; Title2.Text = string.Empty; FadeIn(); return; } Song currentTrack = trackBeforeAction; string prevTitle1 = Title1.Text; string prevTitle2 = Title2.Text; switch (action) { case SpotifyAction.PlayPause: if (trackBeforeAction != null) { //We pressed pause Title1.Text = "Paused"; Title2.Text = trackBeforeAction.ToString(); FadeIn(); } currentSong = null; //If we presses play this will force a toast to display in next timer event. break; case SpotifyAction.Stop: currentSong = null; Title1.Text = "Stopped"; Title2.Text = trackBeforeAction.ToString(); FadeIn(); break; case SpotifyAction.SettingsSaved: Title1.Text = SETTINGS_TEXT; Title2.Text = "Here is a preview of your settings!"; FadeIn(); break; case SpotifyAction.NextTrack: //No need to handle break; case SpotifyAction.PreviousTrack: //No need to handle break; case SpotifyAction.VolumeUp: Title1.Text = VOLUME_UP_TEXT; Title2.Text = currentTrack.ToString(); FadeIn(); break; case SpotifyAction.VolumeDown: Title1.Text = VOLUME_DOWN_TEXT; Title2.Text = currentTrack.ToString(); FadeIn(); break; case SpotifyAction.Mute: Title1.Text = MUTE_ON_OFF_TEXT; Title2.Text = currentTrack.ToString(); FadeIn(); break; case SpotifyAction.ShowToast: if (currentTrack == null || !currentTrack.IsValid()) { toastIcon = DEFAULT_ICON; Title1.Text = NOTHINGS_PLAYING; Title2.Text = string.Empty; } else { if (currentTrack != null && currentTrack.IsValid()) { toastIcon = currentTrack.CoverArtUrl; Title1.Text = currentTrack.Artist; Title2.Text = currentTrack.Track; } } FadeIn(force: true); break; case SpotifyAction.ShowSpotify: //No need to handle break; case SpotifyAction.ThumbsUp: toastIcon = "Resources/thumbs_up.png"; Title1.Text = "Thumbs Up!"; Title2.Text = currentTrack.ToString(); FadeIn(); break; case SpotifyAction.ThumbsDown: toastIcon = "Resources/thumbs_down.png"; Title1.Text = "Thumbs Down :("; Title2.Text = currentTrack.ToString(); FadeIn(); break; } }
public static void SendAction(SpotifyAction a) { if (!Spotify.IsRunning()) { return; } // bah. Because control cannot fall through cases we need to special case volume if (SettingsXml.Current.ChangeSpotifyVolumeOnly) { if (a == SpotifyAction.VolumeUp) { Telemetry.TrackEvent(TelemetryCategory.Action, Telemetry.TelemetryEvent.Action.VolumeUp); VolumeHelper.IncrementVolume("Spotify"); return; } else if (a == SpotifyAction.VolumeDown) { Telemetry.TrackEvent(TelemetryCategory.Action, Telemetry.TelemetryEvent.Action.VolumeDown); VolumeHelper.DecrementVolume("Spotify"); return; } else if (a == SpotifyAction.Mute) { Telemetry.TrackEvent(TelemetryCategory.Action, Telemetry.TelemetryEvent.Action.Mute); VolumeHelper.ToggleApplicationMute("Spotify"); return; } } switch (a) { case SpotifyAction.CopyTrackInfo: case SpotifyAction.ShowToast: //Nothing break; case SpotifyAction.ShowSpotify: Telemetry.TrackEvent(TelemetryCategory.Action, Telemetry.TelemetryEvent.Action.ShowSpotify); if (Spotify.IsMinimized()) { ShowSpotify(); } else { Minimize(); } break; case SpotifyAction.FastForward: Telemetry.TrackEvent(TelemetryCategory.Action, Telemetry.TelemetryEvent.Action.FastForward); SendComplexKeys("+{Right}"); break; case SpotifyAction.Rewind: Telemetry.TrackEvent(TelemetryCategory.Action, Telemetry.TelemetryEvent.Action.Rewind); SendComplexKeys("+{Left}"); break; default: Telemetry.TrackEvent(TelemetryCategory.Action, Telemetry.TelemetryEvent.Action.Default + a.ToString()); Win32.SendMessage(GetSpotify(), Win32.Constants.WM_APPCOMMAND, IntPtr.Zero, new IntPtr((long)a)); break; } }
public static void SendAction(SpotifyAction a) { if (!Spotify.IsAvailable()) return; switch (a) { case SpotifyAction.CopyTrackInfo: case SpotifyAction.ShowSpotify: ShowSpotify(); break; default: Win32.SendMessage(GetSpotify(), Win32.Constants.WM_APPCOMMAND, IntPtr.Zero, new IntPtr((long)a)); break; } }
public void DisplayAction(SpotifyAction action, string trackBeforeAction) { //Anything that changes track doesn't need to be handled since //that will be handled in the timer event. const string VOLUME_UP_TEXT = "Volume ++"; const string VOLUME_DOWN_TEXT = "Volume --"; const string MUTE_ON_OFF_TEXT = "Mute On/Off"; const string NOTHINGS_PLAYING = "Nothing's playing"; const string PAUSED_TEXT = "Paused"; const string STOPPED_TEXT = "Stopped"; const string SETTINGS_TEXT = "Settings saved"; if (!Spotify.IsAvailable() && action != SpotifyAction.SettingsSaved) { coverUrl = "SpotifyToastifyLogo.png"; Title1.Text = "Spotify not available!"; Title2.Text = string.Empty; FadeIn(); return; } string currentTrack = Spotify.GetCurrentTrack(); string prevTitle1 = Title1.Text; string prevTitle2 = Title2.Text; switch (action) { case SpotifyAction.PlayPause: if (!string.IsNullOrEmpty(trackBeforeAction)) { //We pressed pause Title1.Text = "Paused"; Title2.Text = trackBeforeAction; FadeIn(); } previousTitle = string.Empty; //If we presses play this will force a toast to display in next timer event. break; case SpotifyAction.Stop: previousTitle = string.Empty; Title1.Text = "Stopped"; Title2.Text = trackBeforeAction; FadeIn(); break; case SpotifyAction.SettingsSaved: Title1.Text = SETTINGS_TEXT; Title2.Text = "Here is a preview of your settings!"; FadeIn(); break; case SpotifyAction.NextTrack: //No need to handle break; case SpotifyAction.PreviousTrack: //No need to handle break; case SpotifyAction.VolumeUp: Title1.Text = VOLUME_UP_TEXT; Title2.Text = currentTrack; FadeIn(); break; case SpotifyAction.VolumeDown: Title1.Text = VOLUME_DOWN_TEXT; Title2.Text = currentTrack; FadeIn(); break; case SpotifyAction.Mute: Title1.Text = MUTE_ON_OFF_TEXT; Title2.Text = currentTrack; FadeIn(); break; case SpotifyAction.ShowToast: if (string.IsNullOrEmpty(currentTrack) && Title1.Text != PAUSED_TEXT && Title1.Text != STOPPED_TEXT) { coverUrl = "SpotifyToastifyLogo.png"; Title1.Text = NOTHINGS_PLAYING; Title2.Text = string.Empty; } else { string part1, part2; if (SplitTitle(currentTrack, out part1, out part2)) { Title1.Text = part2; Title2.Text = part1; } } FadeIn(force: true); break; case SpotifyAction.ShowSpotify: //No need to handle break; } }
public SpotifyActionControl(ActionContainerControl containerControl, SpotifyAction action) : this(containerControl) { this.action = action; }
private void SendCommand(SpotifyAction Code) { SendMessage(_spotifyProcess.MainWindowHandle, 0x0319, new IntPtr(0), new IntPtr((int)Code)); }
public void DisplayAction(SpotifyAction action, string trackBeforeAction) { //Anything that changes track doesn't need to be handled since //that will be handled in the timer event. const string VOLUME_UP_TEXT = "Volume ++"; const string VOLUME_DOWN_TEXT = "Volume --"; const string MUTE_ON_OFF_TEXT = "Mute On/Off"; const string NOTHINGS_PLAYING = "Nothing's playing"; const string PAUSED_TEXT = "Paused"; const string STOPPED_TEXT = "Stopped"; const string SETTINGS_TEXT = "Settings saved"; string currentTitle = currentTrack.Name; string prevTitle1 = Title1.Text; string prevTitle2 = Title2.Text; switch (action) { case SpotifyAction.PlayPause: if (!string.IsNullOrEmpty(trackBeforeAction)) { //We pressed pause Title1.Text = "Paused"; Title2.Text = trackBeforeAction; FadeIn(); } break; case SpotifyAction.Stop: Title1.Text = "Stopped"; Title2.Text = trackBeforeAction; FadeIn(); break; case SpotifyAction.SettingsSaved: Title1.Text = SETTINGS_TEXT; Title2.Text = "Here is a preview of your settings!"; FadeIn(); break; case SpotifyAction.NextTrack: //No need to handle break; case SpotifyAction.PreviousTrack: //No need to handle break; case SpotifyAction.VolumeUp: Title1.Text = VOLUME_UP_TEXT; Title2.Text = currentTitle; FadeIn(); break; case SpotifyAction.VolumeDown: Title1.Text = VOLUME_DOWN_TEXT; Title2.Text = currentTitle; FadeIn(); break; case SpotifyAction.Mute: Title1.Text = MUTE_ON_OFF_TEXT; Title2.Text = currentTitle; FadeIn(); break; case SpotifyAction.ShowToast: //if (string.IsNullOrEmpty(currentTrack) && Title1.Text != PAUSED_TEXT && Title1.Text != STOPPED_TEXT) //{ // coverUrl = "SpotifyToastifyLogo.png"; // if (SettingsXml.Current.UseSpotifyBeta) // { // Title1.Text = "No Spotify Beta Support :("; // Title2.Text = "Hotkeys will still work"; // } // else // { // Title1.Text = NOTHINGS_PLAYING; // Title2.Text = string.Empty; // } //} //else //{ // string part1, part2; // if (SplitTitle(currentTrack, out part1, out part2)) // { // Title1.Text = part2; // Title2.Text = part1; // } //} FadeIn(force: true); break; case SpotifyAction.ShowSpotify: //No need to handle break; } }