void controler_SpotifyStatusChanged(Controller.SpotifyController sender, SpotifyStatus obj) { if (obj == SpotifyStatus.TrackChanged || obj == SpotifyStatus.Playing) { this.Dispatcher.BeginInvoke(new Action <Controller.SpotifyController>(ShowBalloon), sender); } }
private void RaiseSpotifyStatusChanged(SpotifyStatus status) { this.Status = status; Action <SpotifyController, SpotifyStatus> handler = SpotifyStatusChanged; if (handler != null) { handler(this, status); } }
internal static ICollection <Process> GetSpotifyProcesses() { var spotifyProcesses = new List <Process>(); foreach (var process in Process.GetProcesses()) { if (SpotifyStatus.WindowTitleIsSpotify(process.ProcessName)) { spotifyProcesses.Add(process); } } return(spotifyProcesses); }
public void MapSpotifyTrackToTrack(Track track, FullTrack spotifyTrack) { var performers = GetAlbumArtistFromSimpleArtistList(spotifyTrack.Artists); var(titleParts, separatorType) = SpotifyStatus.GetTitleTags(spotifyTrack.Name, 2); track.SetArtistFromApi(performers.FirstOrDefault()); track.SetTitleFromApi(SpotifyStatus.GetTitleTag(titleParts, 1)); track.SetTitleExtendedFromApi(SpotifyStatus.GetTitleTag(titleParts, 2), separatorType); track.AlbumPosition = spotifyTrack.TrackNumber; track.Performers = performers; track.Disc = spotifyTrack.DiscNumber; }
private void SpotifyStatusSpotifyStandingBy_ReturnsExpectingTrack() { var expectedTrack = new Track { Artist = "Spotify" }; var spotifyWindowInfo = new SpotifyWindowInfo { WindowTitle = "Spotify", IsPlaying = false }; var status = new SpotifyStatus(spotifyWindowInfo); Assert.Equal(expectedTrack, status.CurrentTrack); Assert.Equal("Spotify", status.CurrentTrack.ToString()); }
internal void SpotifyStatusSpotifyStandingBy_ReturnsExpectingTrack() { var expectedTrack = new Track { Artist = Constants.SPOTIFY }; var spotifyWindowInfo = new SpotifyWindowInfo { WindowTitle = Constants.SPOTIFY, IsPlaying = false }; var status = new SpotifyStatus(spotifyWindowInfo); Assert.Equal(expectedTrack, status.CurrentTrack); Assert.Equal(Constants.SPOTIFY, status.CurrentTrack.ToString()); }
public async Task <ISpotifyStatus> GetSpotifyStatus() { var(processTitle, isSpotifyAudioPlaying) = await GetSpotifyTitle(); var isWindowTitledSpotify = SpotifyStatus.WindowTitleIsSpotify(processTitle); if (string.IsNullOrWhiteSpace(processTitle)) { return(null); } var spotifyWindowInfo = new SpotifyWindowInfo { WindowTitle = processTitle, IsPlaying = isSpotifyAudioPlaying || !isWindowTitledSpotify }; return(new SpotifyStatus(spotifyWindowInfo)); }
private void SpotifyStatusSpotifyPlayingAdOrUnknown_ReturnsExpectingTrack(string windowTitle) { var expectedTrack = new Track { Artist = windowTitle, Title = null, TitleExtended = null, Playing = true, Ad = true }; var spotifyWindowInfo = new SpotifyWindowInfo { WindowTitle = windowTitle, IsPlaying = true }; var status = new SpotifyStatus(spotifyWindowInfo); Assert.Equal(expectedTrack, status.CurrentTrack); Assert.Equal(expectedTrack.ToString(), status.CurrentTrack.ToString()); }
private void SpotifyStatusTrackPlaying_ReturnsExpectingTrack(string windowTitle, bool isTitleExtended) { var expectedTrack = new Track { Artist = "Artist Name", Title = "Song Title", TitleExtended = isTitleExtended ? "Live" : "", Playing = true, Ad = false }; var spotifyWindowInfo = new SpotifyWindowInfo { WindowTitle = windowTitle, IsPlaying = true }; var status = new SpotifyStatus(spotifyWindowInfo); Assert.Equal(expectedTrack, status.CurrentTrack); Assert.Equal(windowTitle, status.CurrentTrack.ToString()); }
internal void SpotifyStatusWindowTitleIsSpotify_ReturnsWhenItMatches(string value, bool expected) { var actual = SpotifyStatus.WindowTitleIsSpotify(value); Assert.Equal(expected, actual); }