コード例 #1
0
        private void StopBtn_Click(object sender, EventArgs e)
        {
            try
            {
                PlayerProcess.Kill();
                _currentRadioIndex = -1;

                _title          = "TRadioPlayer";
                TitleLabel.Text = _title;
                TaskbarManager.Instance.SetOverlayIcon(null, "Stopped");
            }
            catch (Exception)
            {
                // ignored
            }
        }
コード例 #2
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     // save log to log.txt file
     // todo: change file path
     File.WriteAllLines("log.txt", _log, Encoding.UTF8);
     _closing = true;
     try
     {
         PlayerProcess.Kill();
     }
     catch (Exception)
     {
         // ignored
     }
     SaveSettings();
     _radioDb.WriteCategoriesToFile(_radioCategories);
     //_radioDb.WriteDataToFile(_radioInfos);
 }
コード例 #3
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
        }