Ver código fonte

Added 3FM, added custom Radio URL

Kenneth van Ewijk 10 anos atrás
pai
commit
17eaac40bf

+ 79 - 33
MusicPlayer/MusicPlayer/MainForm.Designer.cs

@@ -31,7 +31,7 @@ namespace MusicPlayer
         private void InitializeComponent()
         {
             this.components = new System.ComponentModel.Container();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
             this.SongsTableView = new System.Windows.Forms.DataGridView();
             this.GenreListBox = new System.Windows.Forms.ListBox();
@@ -59,6 +59,12 @@ namespace MusicPlayer
             this.ShuffleSongButton = new System.Windows.Forms.ToolStripMenuItem();
             this.playlistToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.makeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.radioToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
+            this.qDanceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.customToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.RadioStationTextBox = new System.Windows.Forms.ToolStripTextBox();
+            this.SetRadioStationButton = new System.Windows.Forms.ToolStripMenuItem();
             this.searchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.SearchGenresToolStripLabel = new System.Windows.Forms.ToolStripMenuItem();
             this.SearchGenresTextBox = new System.Windows.Forms.ToolStripTextBox();
@@ -93,9 +99,8 @@ namespace MusicPlayer
             this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
             this.NotifyMenuStripNextButton = new System.Windows.Forms.ToolStripMenuItem();
             this.NotifyMenuStripPreviousButton = new System.Windows.Forms.ToolStripMenuItem();
-            this.radioToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
-            this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
-            this.qDanceToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+            this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
+            this.fMToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             ((System.ComponentModel.ISupportInitialize)(this.SongsTableView)).BeginInit();
             this.MainPanel.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.SplitContainer)).BeginInit();
@@ -115,14 +120,14 @@ namespace MusicPlayer
             this.SongsTableView.AllowUserToResizeRows = false;
             this.SongsTableView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
             this.SongsTableView.BackgroundColor = System.Drawing.SystemColors.Control;
-            dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
-            dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.ControlLight;
-            dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-            dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText;
-            dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
-            dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
-            dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
-            this.SongsTableView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2;
+            dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
+            dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.ControlLight;
+            dataGridViewCellStyle3.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+            dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
+            dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
+            dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
+            dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
+            this.SongsTableView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle3;
             this.SongsTableView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.SongsTableView.Dock = System.Windows.Forms.DockStyle.Fill;
             this.SongsTableView.Location = new System.Drawing.Point(0, 0);
@@ -279,9 +284,9 @@ namespace MusicPlayer
             this.viewToolStripMenuItem,
             this.playbackToolStripMenuItem,
             this.playlistToolStripMenuItem,
-            this.radioToolStripMenuItem,
             this.searchToolStripMenuItem,
-            this.serverToolStripMenuItem});
+            this.serverToolStripMenuItem,
+            this.radioToolStripMenuItem});
             this.MenuStrip.Location = new System.Drawing.Point(0, 0);
             this.MenuStrip.Name = "MenuStrip";
             this.MenuStrip.Size = new System.Drawing.Size(784, 24);
@@ -397,6 +402,53 @@ namespace MusicPlayer
             this.makeToolStripMenuItem.Text = "Create / Edit";
             this.makeToolStripMenuItem.Click += new System.EventHandler(this.makeToolStripMenuItem_Click);
             // 
+            // radioToolStripMenuItem
+            // 
+            this.radioToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.toolStripMenuItem2,
+            this.fMToolStripMenuItem,
+            this.qDanceToolStripMenuItem,
+            this.toolStripSeparator5,
+            this.customToolStripMenuItem});
+            this.radioToolStripMenuItem.Name = "radioToolStripMenuItem";
+            this.radioToolStripMenuItem.Size = new System.Drawing.Size(49, 20);
+            this.radioToolStripMenuItem.Text = "Radio";
+            // 
+            // toolStripMenuItem2
+            // 
+            this.toolStripMenuItem2.Name = "toolStripMenuItem2";
+            this.toolStripMenuItem2.Size = new System.Drawing.Size(152, 22);
+            this.toolStripMenuItem2.Text = "538";
+            this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click);
+            // 
+            // qDanceToolStripMenuItem
+            // 
+            this.qDanceToolStripMenuItem.Name = "qDanceToolStripMenuItem";
+            this.qDanceToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+            this.qDanceToolStripMenuItem.Text = "Q-Dance";
+            this.qDanceToolStripMenuItem.Click += new System.EventHandler(this.qDanceToolStripMenuItem_Click);
+            // 
+            // customToolStripMenuItem
+            // 
+            this.customToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.RadioStationTextBox,
+            this.SetRadioStationButton});
+            this.customToolStripMenuItem.Name = "customToolStripMenuItem";
+            this.customToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+            this.customToolStripMenuItem.Text = "Custom";
+            // 
+            // RadioStationTextBox
+            // 
+            this.RadioStationTextBox.Name = "RadioStationTextBox";
+            this.RadioStationTextBox.Size = new System.Drawing.Size(100, 23);
+            // 
+            // SetRadioStationButton
+            // 
+            this.SetRadioStationButton.Name = "SetRadioStationButton";
+            this.SetRadioStationButton.Size = new System.Drawing.Size(160, 22);
+            this.SetRadioStationButton.Text = "Set";
+            this.SetRadioStationButton.Click += new System.EventHandler(this.SetRadioStationButton_Click);
+            // 
             // searchToolStripMenuItem
             // 
             this.searchToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -697,28 +749,17 @@ namespace MusicPlayer
             this.NotifyMenuStripPreviousButton.Text = "Previous";
             this.NotifyMenuStripPreviousButton.Click += new System.EventHandler(this.NotifyMenuStripPreviousButton_Click);
             // 
-            // radioToolStripMenuItem
-            // 
-            this.radioToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
-            this.toolStripMenuItem2,
-            this.qDanceToolStripMenuItem});
-            this.radioToolStripMenuItem.Name = "radioToolStripMenuItem";
-            this.radioToolStripMenuItem.Size = new System.Drawing.Size(49, 20);
-            this.radioToolStripMenuItem.Text = "Radio";
-            // 
-            // toolStripMenuItem2
+            // toolStripSeparator5
             // 
-            this.toolStripMenuItem2.Name = "toolStripMenuItem2";
-            this.toolStripMenuItem2.Size = new System.Drawing.Size(152, 22);
-            this.toolStripMenuItem2.Text = "538";
-            this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click);
+            this.toolStripSeparator5.Name = "toolStripSeparator5";
+            this.toolStripSeparator5.Size = new System.Drawing.Size(149, 6);
             // 
-            // qDanceToolStripMenuItem
+            // fMToolStripMenuItem
             // 
-            this.qDanceToolStripMenuItem.Name = "qDanceToolStripMenuItem";
-            this.qDanceToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
-            this.qDanceToolStripMenuItem.Text = "Q-Dance";
-            this.qDanceToolStripMenuItem.Click += new System.EventHandler(this.qDanceToolStripMenuItem_Click);
+            this.fMToolStripMenuItem.Name = "fMToolStripMenuItem";
+            this.fMToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+            this.fMToolStripMenuItem.Text = "3FM";
+            this.fMToolStripMenuItem.Click += new System.EventHandler(this.fMToolStripMenuItem_Click);
             // 
             // MainForm
             // 
@@ -818,6 +859,11 @@ namespace MusicPlayer
         private System.Windows.Forms.ToolStripMenuItem radioToolStripMenuItem;
         private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
         private System.Windows.Forms.ToolStripMenuItem qDanceToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem customToolStripMenuItem;
+        private System.Windows.Forms.ToolStripTextBox RadioStationTextBox;
+        private System.Windows.Forms.ToolStripMenuItem SetRadioStationButton;
+        private System.Windows.Forms.ToolStripMenuItem fMToolStripMenuItem;
+        private System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
     }
 }
 

+ 36 - 9
MusicPlayer/MusicPlayer/MainForm.cs

@@ -167,6 +167,11 @@ namespace MusicPlayer
                 NotifyMenuStripStopButton.Enabled = true;
             }
 
+            if (RadioStationTextBox.Text.Length <= 10)
+                SetRadioStationButton.Enabled = false;
+            else
+                SetRadioStationButton.Enabled = true;
+
             if(PlayNextSongButton.Checked)
             {
                 ShuffleSongButton.Enabled = true;
@@ -203,15 +208,18 @@ namespace MusicPlayer
 
             if (songFinished)
             {
-                Thread.Sleep(20);
-
-                if (PlayNextSongButton.Checked)
-                {
-                    NextButton_Click(this, new EventArgs());
-                }
-                else if (LoopSongButton.Checked)
+                if (! (main.audio.CurrentSong is RadioStation) )
                 {
-                    main.audio.Play(main.audio.CurrentSong);
+                    Thread.Sleep(20);
+
+                    if (PlayNextSongButton.Checked)
+                    {
+                        NextButton_Click(this, new EventArgs());
+                    }
+                    else if (LoopSongButton.Checked)
+                    {
+                        main.audio.Play(main.audio.CurrentSong);
+                    }
                 }
 
                 songFinished = false;
@@ -531,7 +539,26 @@ namespace MusicPlayer
 
         private void qDanceToolStripMenuItem_Click(object sender, EventArgs e)
         {
-            main.audio.Play(new RadioStation("538", main.api, "            http://stream01.platform02.true.nl:8000/qdance-hard"));
+            main.audio.Play(new RadioStation("Q-Dance", main.api, "http://stream01.platform02.true.nl:8000/qdance-hard"));
+        }
+
+        private void fMToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            main.audio.Play(new RadioStation("Q-Dance", main.api, "http://icecast.omroep.nl/3fm-bb-aac"));
         }
+
+        private void SetRadioStationButton_Click(object sender, EventArgs e)
+        {
+            string input = RadioStationTextBox.Text;
+
+            if(Main.CheckURLValid(input))
+            {
+                main.audio.Play(new RadioStation(Main.GetDomain(input), main.api, input));       
+            }
+
+            RadioStationTextBox.Text = "";
+        }
+
+        
     }
 }