private void SetSongInfo(ref SpotifyWindowInfo spotifyWindowInfo) { var tags = spotifyWindowInfo.WindowTitle.Split(_windowTitleSeparator, 3, StringSplitOptions.None); var isPlaying = spotifyWindowInfo.IsPlaying || !spotifyWindowInfo.IsTitledSpotify; var isAd = tags.Length < 2; CurrentTrack = new Track { Ad = isAd && isPlaying, Playing = isPlaying, Artist = GetTitleTag(tags, 1), Title = GetTitleTag(tags, 2), TitleExtended = GetTitleTag(tags, 3), }; }
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 ISpotifyStatus GetSpotifyStatus() { var isSpotifyPlaying = _spotifyAudioSession.IsSpotifyCurrentlyPlaying(); var processTitle = GetSpotifyTitle(); if (string.IsNullOrWhiteSpace(processTitle)) { return(null); } var spotifyWindowInfo = new SpotifyWindowInfo { WindowTitle = processTitle, IsPlaying = isSpotifyPlaying }; return(new SpotifyStatus(spotifyWindowInfo)); }
public async Task <ISpotifyStatus> GetSpotifyStatus() { var(processTitle, isSpotifyAudioPlaying) = await GetSpotifyTitle(); var isWindowTitledSpotify = processTitle.IsNullOrSpotifyIdleState(); if (string.IsNullOrWhiteSpace(processTitle)) { return(null); } var spotifyWindowInfo = new SpotifyWindowInfo { WindowTitle = processTitle, IsPlaying = isSpotifyAudioPlaying || !isWindowTitledSpotify }; return(new SpotifyStatus(spotifyWindowInfo)); }
public SpotifyStatus(SpotifyWindowInfo spotifyWindowInfo) { var tags = GetDashTags(spotifyWindowInfo.WindowTitle, 2); var longTitlePart = GetTitleTag(tags, 2); var(titleTags, separatorType) = GetTitleTags(longTitlePart ?? "", 2); var isPlaying = spotifyWindowInfo.IsPlaying; var isLookingLikeAnAd = tags.Length < 2 || tags.First() == Constants.SPOTIFY; CurrentTrack = new Track { Ad = spotifyWindowInfo.IsTitledAd || (isLookingLikeAnAd && isPlaying), Playing = isPlaying, Artist = GetTitleTag(tags, 1), Title = GetTitleTag(titleTags, 1), TitleExtended = GetTitleTag(titleTags, 2), TitleExtendedSeparatorType = separatorType }; }
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()); }
public SpotifyStatus(SpotifyWindowInfo spotifyWindowInfo) { _windowTitleSeparator = new[] { " - " }; SetSongInfo(ref spotifyWindowInfo); }