Ejemplo n.º 1
0
        /// <summary>
        /// load the xml file
        /// </summary>
        private void InitializeStations()
        {
            try
            {
                notifyIcon = new NotifyIcon();
                notifyIcon.Text = "Tamil FM";
                notifyIcon.Visible = true;
                notifyIcon.Icon = new Icon(GetType(), "Tamil16.ICO"); //Thanks to Hasaki for this.
                notifyIcon.ContextMenuStrip = ctxtMenu;
                notifyIcon.MouseClick += new MouseEventHandler(notifyIcon_MouseClick);

                Station st = new Station();
                DataSet set = new DataSet();
                FileInfo fileInfo = new FileInfo(Application.ExecutablePath);
                set.ReadXml(fileInfo.DirectoryName + "\\stations.xml");
                foreach (DataRow rw in set.Tables["station"].Rows)
                {
                    st.Name = rw["Name"] as string;
                    st.URL = rw["URL"] as string;
                    st.PlayerHint = rw["PlayerHint"] as string;
                    stationsList.Add(st.Name, st);
                    comboStation.Items.Add(st.Name);
                    stationsToolStripMenuItem.DropDownItems.Add(st.Name);
                }
                comboStation.SelectedIndex = 0;

            }
            catch (Exception ex)
            {
                ThrowError(ex.Message);
                Application.Exit();
            }

        } 
Ejemplo n.º 2
0
 /// <summary>
 /// change the station
 /// </summary>
 /// <param name="strStationName">station name</param>
 private void ApplyStation(string strStationName)
 {
     try
     {
         curStation = stationsList[strStationName];
         ResetPlayers(curStation.PlayerHint);
         switch (curStation.PlayerHint)
         {
             case "MPLAYER":
                 if (mediaPlayer == null)
                 {
                     try
                     {
                         loadPlayer("MPLAYER");
                         if (mediaPlayer == null)
                         {
                             MessageBox.Show("Please install windows media player 7 or higher", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                             return;
                         }
                     }
                     catch (Exception ex)
                     {
                         MessageBox.Show("Please install windows media player 7 or higher\n\nError:\n" + ex.Message, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         return;
                     }
                 }
                 mediaPlayer.URL = curStation.URL;
                 break;
             case "VLCPLAYER":
                 if (vlcPlayer == null)
                 {
                     try
                     {
                         loadPlayer("VLCPLAYER");
                         if (vlcPlayer == null)
                         {
                             MessageBox.Show("Please install vlc player\n and \n register the vlc player activex", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                             return;
                         }
                     }
                     catch(Exception ex)
                     {
                         MessageBox.Show("Please install vlc player\n and \n register the vlc player activex\n\nError:\n" + ex.Message, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         return;
                     }
                 }
                 vlcVolumeCtrl.Value = vlcPlayer.Volume;
                 vlcPlayer.playlistClear();
                 vlcPlayer.addTarget(curStation.URL, null, VLCPlaylistMode.VLCPlayListAppendAndGo, 0);
                 laVlcDesc.Text = "Playing...";
                 break;
         }
         resizePlayer(curStation.PlayerHint);
         this.Text = "Radio Tamil - " + curStation.Name;
         notifyIcon.Text = this.Text;
     }
     catch (Exception ex)
     {
         ThrowError(ex.Message);
     }
 }