Beispiel #1
0
        private void ToggleVLC()
        {
            this.toolStripMenuItemSpotify.Checked    = false;
            this.toolStripMenuItemItunes.Checked     = false;
            this.toolStripMenuItemWinamp.Checked     = false;
            this.toolStripMenuItemFoobar2000.Checked = false;
            this.toolStripMenuItemVlc.Checked        = true;

            Globals.CurrentPlayer.Unload();
            Globals.CurrentPlayer = new VLC();
            Globals.CurrentPlayer.Load();

            Globals.PlayerSelection = Globals.MediaPlayerSelection.VLC;
            TextHandler.UpdateTextAndEmptyFile(Globals.ResourceManager.GetString("SwitchedToVLC"));
        }
Beispiel #2
0
        private void App_OnPlayerQuittingEvent()
        {
            if (Globals.SaveAlbumArtwork)
            {
                this.SaveBlankImage();
            }

            if (Globals.EmptyFileIfNoTrackPlaying)
            {
                TextHandler.UpdateTextAndEmptyFile(Globals.ResourceManager.GetString("iTunesNotRunning"));
            }
            else
            {
                TextHandler.UpdateText(Globals.ResourceManager.GetString("iTunesNotRunning"));
            }
        }
Beispiel #3
0
        private void App_OnPlayerStopEvent(object o)
        {
            if (Globals.SaveAlbumArtwork)
            {
                this.SaveBlankImage();
            }

            if (Globals.EmptyFileIfNoTrackPlaying)
            {
                TextHandler.UpdateTextAndEmptyFile(Globals.ResourceManager.GetString("NoTrackPlaying"));
            }
            else
            {
                TextHandler.UpdateText(Globals.ResourceManager.GetString("NoTrackPlaying"));
            }
        }
Beispiel #4
0
        public override void Update()
        {
            if (!this.Found)
            {
                this.Handle = UnsafeNativeMethods.FindWindow("QWidget", "VLC media player");

                this.Found      = true;
                this.NotRunning = false;
            }
            else
            {
                // Make sure the process is still valid.
                if (this.Handle != IntPtr.Zero && this.Handle != null)
                {
                    int windowTextLength = UnsafeNativeMethods.GetWindowText(this.Handle, this.Title, this.Title.Capacity);

                    string vlcTitle = this.Title.ToString();

                    this.Title.Clear();

                    // If the window title length is 0 then the process handle is not valid.
                    if (windowTextLength > 0)
                    {
                        // Only update the system tray text and text file text if the title changes.
                        if (vlcTitle != this.LastTitle)
                        {
                            if (vlcTitle.Equals("VLC media player"))
                            {
                                if (Globals.EmptyFileIfNoTrackPlaying)
                                {
                                    TextHandler.UpdateTextAndEmptyFile(Globals.ResourceManager.GetString("NoTrackPlaying"));
                                }
                                else
                                {
                                    TextHandler.UpdateText(Globals.ResourceManager.GetString("NoTrackPlaying"));
                                }
                            }
                            else
                            {
                                string windowTitleFull = vlcTitle.Replace(" - VLC media player", string.Empty);

                                if (Globals.SaveAlbumArtwork)
                                {
                                    this.SaveBlankImage();
                                }

                                TextHandler.UpdateText(windowTitleFull.Trim());
                            }

                            this.LastTitle = vlcTitle;
                        }
                    }
                    else
                    {
                        if (!this.NotRunning)
                        {
                            if (Globals.SaveAlbumArtwork)
                            {
                                this.SaveBlankImage();
                            }

                            if (Globals.EmptyFileIfNoTrackPlaying)
                            {
                                TextHandler.UpdateTextAndEmptyFile(Globals.ResourceManager.GetString("VLCIsNotRunning"));
                            }
                            else
                            {
                                TextHandler.UpdateText(Globals.ResourceManager.GetString("VLCIsNotRunning"));
                            }

                            this.Found      = false;
                            this.NotRunning = true;
                        }
                    }
                }
                else
                {
                    if (!this.NotRunning)
                    {
                        if (Globals.SaveAlbumArtwork)
                        {
                            this.SaveBlankImage();
                        }

                        if (Globals.EmptyFileIfNoTrackPlaying)
                        {
                            TextHandler.UpdateTextAndEmptyFile(Globals.ResourceManager.GetString("VLCIsNotRunning"));
                        }
                        else
                        {
                            TextHandler.UpdateText(Globals.ResourceManager.GetString("VLCIsNotRunning"));
                        }

                        this.Found      = false;
                        this.NotRunning = true;
                    }
                }
            }
        }
Beispiel #5
0
        public override void Update()
        {
            if (!this.Found)
            {
                this.Handle = UnsafeNativeMethods.FindWindow("SpotifyMainWindow", null);

                this.Found      = true;
                this.NotRunning = false;
            }
            else
            {
                // Make sure the process is still valid.
                if (this.Handle != IntPtr.Zero && this.Handle != null)
                {
                    int windowTextLength = UnsafeNativeMethods.GetWindowText(this.Handle, this.Title, this.Title.Capacity);

                    string spotifyTitle = this.Title.ToString();

                    this.Title.Clear();

                    // If the window title length is 0 then the process handle is not valid.
                    if (windowTextLength > 0)
                    {
                        // Only update the system tray text and text file text if the title changes.
                        if (spotifyTitle != this.LastTitle)
                        {
                            if (spotifyTitle == "Spotify")
                            {
                                if (Globals.SaveAlbumArtwork)
                                {
                                    this.SaveBlankImage();
                                }

                                if (Globals.EmptyFileIfNoTrackPlaying)
                                {
                                    TextHandler.UpdateTextAndEmptyFile(Globals.ResourceManager.GetString("NoTrackPlaying"));
                                }
                                else
                                {
                                    TextHandler.UpdateText(Globals.ResourceManager.GetString("NoTrackPlaying"));
                                }
                            }
                            else
                            {
                                // Spotify window titles look like "Spotify - Artist – Song Title".
                                string   windowTitleFull = spotifyTitle.Replace("Spotify - ", string.Empty);
                                string[] windowTitle     = windowTitleFull.Split('–');

                                string artist    = windowTitle[0].Trim();
                                string songTitle = windowTitle[1].Trim();
                                songTitle = songTitle.Replace(" - Explicit Album Version", string.Empty);

                                if (Globals.SaveAlbumArtwork || Globals.SaveSeparateFiles)
                                {
                                    this.DownloadJson(artist, songTitle);
                                }

                                if (Globals.SaveAlbumArtwork)
                                {
                                    this.HandleSpotifyAlbumArtwork(songTitle);
                                }

                                if (Globals.SaveSeparateFiles)
                                {
                                    string album = this.HandleSpotifyAlbumName();
                                    TextHandler.UpdateText(songTitle, artist, album);
                                }
                                else
                                {
                                    TextHandler.UpdateText(songTitle, artist);
                                }
                            }

                            this.LastTitle = spotifyTitle;
                        }
                    }
                    else
                    {
                        if (!this.NotRunning)
                        {
                            if (Globals.SaveAlbumArtwork)
                            {
                                this.SaveBlankImage();
                            }

                            if (Globals.EmptyFileIfNoTrackPlaying)
                            {
                                TextHandler.UpdateTextAndEmptyFile(Globals.ResourceManager.GetString("SpotifyIsNotRunning"));
                            }
                            else
                            {
                                TextHandler.UpdateText(Globals.ResourceManager.GetString("SpotifyIsNotRunning"));
                            }

                            this.Found      = false;
                            this.NotRunning = true;
                        }
                    }
                }
                else
                {
                    if (!this.NotRunning)
                    {
                        if (Globals.SaveAlbumArtwork)
                        {
                            this.SaveBlankImage();
                        }

                        if (Globals.EmptyFileIfNoTrackPlaying)
                        {
                            TextHandler.UpdateTextAndEmptyFile(Globals.ResourceManager.GetString("SpotifyIsNotRunning"));
                        }
                        else
                        {
                            TextHandler.UpdateText(Globals.ResourceManager.GetString("SpotifyIsNotRunning"));
                        }

                        this.Found      = false;
                        this.NotRunning = true;
                    }
                }
            }
        }
Beispiel #6
0
        public override void Update()
        {
            if (!this.Found)
            {
                System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcessesByName("foobar2000");

                if (processes.Length > 0)
                {
                    this.Handle = processes[0].MainWindowHandle;
                }

                foreach (var process in processes)
                {
                    process.Dispose();
                }

                processes = null;

                this.Found      = true;
                this.NotRunning = false;
            }
            else
            {
                // Make sure the process is still valid.
                if (this.Handle != IntPtr.Zero && this.Handle != null)
                {
                    int windowTextLength = UnsafeNativeMethods.GetWindowText(this.Handle, this.Title, this.Title.Capacity);

                    string foobar2000Title = this.Title.ToString();

                    this.Title.Clear();

                    // If the window title length is 0 then the process handle is not valid.
                    if (windowTextLength > 0)
                    {
                        // Only update the system tray text and text file text if the title changes.
                        if (foobar2000Title != this.LastTitle)
                        {
                            if (foobar2000Title.StartsWith("foobar2000", StringComparison.OrdinalIgnoreCase))
                            {
                                if (Globals.EmptyFileIfNoTrackPlaying)
                                {
                                    TextHandler.UpdateTextAndEmptyFile(Globals.ResourceManager.GetString("NoTrackPlaying"));
                                }
                                else
                                {
                                    TextHandler.UpdateText(Globals.ResourceManager.GetString("NoTrackPlaying"));
                                }
                            }
                            else
                            {
                                // Winamp window titles look like "[%album artist% - ]['['%album%[ CD%discnumber%][ #%tracknumber%]']' ]%title%[ '//' %track artist%]".
                                // Require that the user use ATF and replace the format with something like:
                                // %artist% – %title%
                                string   windowTitleFull = System.Text.RegularExpressions.Regex.Replace(foobar2000Title, @"\s+\[foobar2000 v\d+\.\d+\.\d+\]", string.Empty);
                                string[] windowTitle     = windowTitleFull.Split('–');

                                // Album artwork not supported by foobar2000
                                if (Globals.SaveAlbumArtwork)
                                {
                                    this.SaveBlankImage();
                                }

                                if (windowTitle.Length > 1)
                                {
                                    string songTitle = windowTitle[0].Trim();
                                    string artist    = windowTitle[1].Trim();
                                    string album     = windowTitle[2].Trim();

                                    TextHandler.UpdateText(songTitle, artist, album);
                                }
                                else
                                {
                                    TextHandler.UpdateText(windowTitle[0].Trim());
                                }
                            }

                            this.LastTitle = foobar2000Title;
                        }
                    }
                    else
                    {
                        if (!this.NotRunning)
                        {
                            if (Globals.SaveAlbumArtwork)
                            {
                                this.SaveBlankImage();
                            }

                            if (Globals.EmptyFileIfNoTrackPlaying)
                            {
                                TextHandler.UpdateTextAndEmptyFile(Globals.ResourceManager.GetString("foobar2000IsNotRunning"));
                            }
                            else
                            {
                                TextHandler.UpdateText(Globals.ResourceManager.GetString("foobar2000IsNotRunning"));
                            }

                            this.Found      = false;
                            this.NotRunning = true;
                        }
                    }
                }
                else
                {
                    if (!this.NotRunning)
                    {
                        if (Globals.SaveAlbumArtwork)
                        {
                            this.SaveBlankImage();
                        }

                        if (Globals.EmptyFileIfNoTrackPlaying)
                        {
                            TextHandler.UpdateTextAndEmptyFile(Globals.ResourceManager.GetString("foobar2000IsNotRunning"));
                        }
                        else
                        {
                            TextHandler.UpdateText(Globals.ResourceManager.GetString("foobar2000IsNotRunning"));
                        }

                        this.Found      = false;
                        this.NotRunning = true;
                    }
                }
            }
        }
Beispiel #7
0
        public override void Update()
        {
            if (!this.Found)
            {
                this.Handle = UnsafeNativeMethods.FindWindow("Winamp v1.x", null);

                this.Found      = true;
                this.NotRunning = false;
            }
            else
            {
                // Make sure the process is still valid.
                if (this.Handle != IntPtr.Zero && this.Handle != null)
                {
                    int windowTextLength = UnsafeNativeMethods.GetWindowText(this.Handle, this.Title, this.Title.Capacity);

                    string winampTitle = this.Title.ToString();

                    this.Title.Clear();

                    // If the window title length is 0 then the process handle is not valid.
                    if (windowTextLength > 0)
                    {
                        // Only update the system tray text and text file text if the title changes.
                        if (winampTitle != this.LastTitle)
                        {
                            if (winampTitle.Contains("- Winamp [Stopped]") || winampTitle.Contains("- Winamp [Paused]"))
                            {
                                if (Globals.EmptyFileIfNoTrackPlaying)
                                {
                                    TextHandler.UpdateTextAndEmptyFile(Globals.ResourceManager.GetString("NoTrackPlaying"));
                                }
                                else
                                {
                                    TextHandler.UpdateText(Globals.ResourceManager.GetString("NoTrackPlaying"));
                                }
                            }
                            else
                            {
                                // Winamp window titles look like "#. Artist - Track - Winamp".
                                // Require that the user use ATF and replace the format with something like:
                                // %artist% – %title%
                                string   windowTitleFull = winampTitle.Replace("- Winamp", string.Empty);
                                string[] windowTitle     = windowTitleFull.Split('–');

                                // Album artwork not supported by Winamp
                                if (Globals.SaveAlbumArtwork)
                                {
                                    this.SaveBlankImage();
                                }

                                if (windowTitle.Length > 1)
                                {
                                    string artist    = windowTitle[0].Trim();
                                    string songTitle = windowTitle[1].Trim();

                                    TextHandler.UpdateText(songTitle, artist);
                                }
                                else
                                {
                                    TextHandler.UpdateText(windowTitle[0].Trim());
                                }
                            }

                            this.LastTitle = winampTitle;
                        }
                    }
                    else
                    {
                        if (!this.NotRunning)
                        {
                            if (Globals.SaveAlbumArtwork)
                            {
                                this.SaveBlankImage();
                            }

                            if (Globals.EmptyFileIfNoTrackPlaying)
                            {
                                TextHandler.UpdateTextAndEmptyFile(Globals.ResourceManager.GetString("WinampIsNotRunning"));
                            }
                            else
                            {
                                TextHandler.UpdateText(Globals.ResourceManager.GetString("WinampIsNotRunning"));
                            }

                            this.Found      = false;
                            this.NotRunning = true;
                        }
                    }
                }
                else
                {
                    if (!this.NotRunning)
                    {
                        if (Globals.SaveAlbumArtwork)
                        {
                            this.SaveBlankImage();
                        }

                        if (Globals.EmptyFileIfNoTrackPlaying)
                        {
                            TextHandler.UpdateTextAndEmptyFile(Globals.ResourceManager.GetString("WinampIsNotRunning"));
                        }
                        else
                        {
                            TextHandler.UpdateText(Globals.ResourceManager.GetString("WinampIsNotRunning"));
                        }

                        this.Found      = false;
                        this.NotRunning = true;
                    }
                }
            }
        }