Exemple #1
0
        public void LoadSettings()
        {
            _eqSettings = _settingReadWrite.ReadEqSettings();

            EnableEQBtn.Checked = _eqSettings.Enabled;
            trackBar1.Value = _eqSettings.EqVal1;
            trackBar2.Value = _eqSettings.EqVal2;
            trackBar3.Value = _eqSettings.EqVal3;
            trackBar4.Value = _eqSettings.EqVal4;
            trackBar5.Value = _eqSettings.EqVal5;
            trackBar6.Value = _eqSettings.EqVal6;
            trackBar7.Value = _eqSettings.EqVal7;
            trackBar8.Value = _eqSettings.EqVal8;
            trackBar9.Value = _eqSettings.EqVal9;
            trackBar10.Value = _eqSettings.EqVal10;
            PresetsList.SelectedIndex = _eqSettings.PresetIndex;

            EnableEQBtn_CheckedChanged(this, null);
        }
Exemple #2
0
        /// <summary>
        /// Starts to play given url
        /// </summary>
        /// <param name="url">Url to play</param>
        private void PlayUrl(string url)
        {
            _failedToOpen = false;
            // kill mpv if it is already running
            try
            {
                PlayerProcess.Kill();
            }
            catch (Exception)
            {
                // ignored
            }
            if (_closing)
            {
                return;
            }
            // update UI
            _title = "TRadioPlayer";
            try
            {
                StatusLabel.Text = "Connecting...";
                TitleLabel.Text = "TRadioPlayer";
                this.Text = "TRadioPlayer";
                StationsList.Refresh();
                RotateTimer.Enabled = true;
                TaskbarManager.Instance.SetOverlayIcon(playIcon, "Playing");
            }
            catch (Exception)
            {
                Invoke((MethodInvoker)delegate
                {
                    StatusLabel.Text = "Connecting...";
                    TitleLabel.Text = "TRadioPlayer";
                    this.Text = "TRadioPlayer";
                    StationsList.Refresh();
                    RotateTimer.Enabled = true;
                    TaskbarManager.Instance.SetOverlayIcon(playIcon, "Playing");
                });
            }
            // start playing radio
            PlayerProcess = new Process();
            // this processtartinfo is copied from the
            // process in the UI. It should never be null.
            if (_startInfo != null)
            {
                PlayerProcess.StartInfo = _startInfo;
            }

            PlayerProcess.StartInfo.FileName = _mpvPath;
            PlayerProcess.StartInfo.Arguments = SongPlayCmd + " --volume " + _volumeLevel.ToString() + " \"" + url + "\"";
            PlayerProcess.ErrorDataReceived += PlayProcess_ErrorDataReceived;
            PlayerProcess.OutputDataReceived += PlayerProcess_OutputDataReceived;
            PlayerProcess.Exited += MusicPlayProcess_Exited;
            PlayerProcess.EnableRaisingEvents = true;
            PlayerProcess.StartInfo.RedirectStandardInput = true;
            PlayerProcess.Start();
            PlayerProcess.BeginErrorReadLine();
            PlayerProcess.BeginOutputReadLine();
            _playerState = PlayerState.Playing;

            #region equalizer

            _eqSettings = _settingReadWrite.ReadEqSettings();
            double[] eqValues = new double[10];
            eqValues[0] = _eqSettings.EqVal1 / 100.0;
            eqValues[1] = _eqSettings.EqVal2 / 100.0;
            eqValues[2] = _eqSettings.EqVal3 / 100.0;
            eqValues[3] = _eqSettings.EqVal4 / 100.0;
            eqValues[4] = _eqSettings.EqVal5 / 100.0;
            eqValues[5] = _eqSettings.EqVal6 / 100.0;
            eqValues[6] = _eqSettings.EqVal7 / 100.0;
            eqValues[7] = _eqSettings.EqVal8 / 100.0;
            eqValues[8] = _eqSettings.EqVal9 / 100.0;
            eqValues[9] = _eqSettings.EqVal10 / 100.0;
            ApplyEq(eqValues);

            #endregion
        }
        public void WriteEqSettings(EqSettings eqSettings)
        {
            var jsonStr = JsonConvert.SerializeObject(eqSettings, Formatting.Indented);

            File.WriteAllText(_eqFilePath, jsonStr, Encoding.UTF8);
        }
 public void WriteEqSettings(EqSettings eqSettings)
 {
     var jsonStr = JsonConvert.SerializeObject(eqSettings, Formatting.Indented);
     File.WriteAllText(_eqFilePath, jsonStr, Encoding.UTF8);
 }