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);
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
        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());
        }
Beispiel #7
0
        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));
        }
Beispiel #8
0
        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());
        }
Beispiel #9
0
        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());
        }
Beispiel #10
0
        internal void SpotifyStatusWindowTitleIsSpotify_ReturnsWhenItMatches(string value, bool expected)
        {
            var actual = SpotifyStatus.WindowTitleIsSpotify(value);

            Assert.Equal(expected, actual);
        }