Esempio n. 1
0
        /// <summary>
        /// plays given radio index
        /// only called from search form
        /// </summary>
        /// <param name="index">index of the radio station to be placed</param>
        public void PlayFromSearchForm(int index)
        {
            RadioInfo radioInfo = _radioInfos[index];

            if (radioInfo != null)
            {
                // update the last played station for that radio category
                _radioCategories[CategoryList.SelectedIndex].LastPlayedStationIndex = index;
                if (_currentRadioIndex > -1)
                {
                    StationsList.Items[_currentRadioIndex].Selected = false;
                }
                _currentRadioIndex = index;
                _activeCategory    = CategoryList.SelectedIndex;
                // make sure list focuses on the station
                StationsList.Items[index].EnsureVisible();
                StationsList.Items[index].Selected = true;
                StationsList.Refresh();

                // play the radio
                PlayUrl(radioInfo.StreamUrl);
            }
            else
            {
                // todo: report this by showing the log
            }
        }
Esempio n. 2
0
        private void favUnFavToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (StationsList.SelectedIndices.Count > 0)
            {
                int index = StationsList.SelectedIndices[0];

                _radioDb.UpdateFavState(_radioInfos[index].Index);
                StationsList.Refresh();
            }
        }
Esempio n. 3
0
 private void MusicPlayProcess_Exited(object sender, EventArgs e)
 {
     _consoleOutput = "Stopped";
     _playerState   = PlayerState.Stopped;
     if (!_closing)
     {
         Invoke((MethodInvoker) delegate
         {
             StatusLabel.Text = _consoleOutput;
             this.Text        = "TRadioPlayer";
             StationsList.Refresh();
         });
     }
 }
Esempio n. 4
0
        /// <summary>
        /// displays radio stations according to the selected category
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CategoryList_SelectedIndexChanged(object sender, EventArgs e)
        {
            LoadStations();
            int lastPlayedIndex = _radioCategories[CategoryList.SelectedIndex].LastPlayedStationIndex;

            if (lastPlayedIndex > -1 && lastPlayedIndex < _radioInfos.Count)
            {
                StationsList.Items[lastPlayedIndex].EnsureVisible();
                StationsList.Items[lastPlayedIndex].Selected = true;
                _currentRadioIndex = lastPlayedIndex;
            }
            StationsList.Refresh();
            StationsList.Update();
        }
Esempio n. 5
0
        private void StationsList_DoubleClick_1(object sender, EventArgs e)
        {
            // start playing selected station
            if (StationsList.SelectedIndices.Count > 0)
            {
                // get radio that will be played
                RadioInfo radioInfo = _radioInfos[StationsList.SelectedIndices[0]];

                // update the last played station for that radio category
                _radioCategories[CategoryList.SelectedIndex].LastPlayedStationIndex = StationsList.SelectedIndices[0];
                _currentRadioIndex = StationsList.SelectedIndices[0];
                _activeCategory    = CategoryList.SelectedIndex;
                StationsList.Refresh();

                // play the radio
                // todo: check links first
                PlayUrl(radioInfo.StreamUrl);
            }
        }
Esempio n. 6
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
        }