Example #1
0
        /*
         * Load settings from Registry to panel
         */
        private void Settings_Load(object sender, EventArgs e)
        {
            if (Registry.Read("songPath") != null)
            {
                songPath.Text = Registry.Read("songPath");
            }

            if (Registry.Read("songFormat") != null)
            {
                songFormat.Text = Registry.Read("songFormat");
            }

            if (Registry.Read("credentialsName") != null)
            {
                credentialsName.Text = Registry.Read("credentialsName");
            }

            if (Registry.Read("credentialsPassword") != null)
            {
                credentialsPassword.Text = Registry.Read("credentialsPassword");
            }

            if (Registry.Read("host") != null)
            {
                host.Text = Registry.Read("host");
            }
        }
Example #2
0
        /*
         * Open player panel / frame
         */
        private void OpenPlayer()
        {
            // Set browserReady to false
            browserReady = false;
            // If the app is not configured
            if (Registry.ValueCount() != 5)
            {
                chromeBrowser = new ChromiumWebBrowser();
                chromeBrowser.LoadHtml(PB_MusicPlayer.Properties.Resources.not_configured_page);
            }
            // When the app is configured
            else
            {
                // Get credentials and parse them into the host
                string   str       = Registry.Read("host");
                string[] splitchar = new string[] { "://" };
                string[] strArr    = str.Split(splitchar, StringSplitOptions.None);
                chromeBrowser = new ChromiumWebBrowser(strArr[0] + "://" + Registry.Read("credentialsName") + ":" + Registry.Read("credentialsPassword") + "@" + strArr[1] + "/ytplayer");
                chromeBrowser.FrameLoadEnd += (sender, args) =>
                {
                    // Wait for the MainFrame to finish loading
                    if (args.Frame.IsMain)
                    {
                        // Call the browser is now ready to talk to it
                        browserReady = true;
                    }
                };
                chromeBrowser.LoadingStateChanged += OnBrowserloadComplete;

                // Register hotkeys
                RegisterHotKey(this.Handle, VK_MEDIA_NEXT_TRACK, 0, VK_MEDIA_NEXT_TRACK);
                RegisterHotKey(this.Handle, VK_MEDIA_PLAY_PAUSE, 0, VK_MEDIA_PLAY_PAUSE);
            }

            // Apply the frame to panel
            panel1.Controls.Add(chromeBrowser);
            chromeBrowser.Dock = DockStyle.Fill;
        }