Kaynağa Gözat

Added support for radio stations

Janco Kock 10 yıl önce
ebeveyn
işleme
7f45afe80f

+ 39 - 9
MusicPlayer/MusicPlayer/MainForm.Designer.cs

@@ -31,7 +31,7 @@ namespace MusicPlayer
         private void InitializeComponent()
         {
             this.components = new System.ComponentModel.Container();
-            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
+            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = 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();
@@ -93,6 +93,9 @@ 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();
             ((System.ComponentModel.ISupportInitialize)(this.SongsTableView)).BeginInit();
             this.MainPanel.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.SplitContainer)).BeginInit();
@@ -112,14 +115,14 @@ namespace MusicPlayer
             this.SongsTableView.AllowUserToResizeRows = false;
             this.SongsTableView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
             this.SongsTableView.BackgroundColor = System.Drawing.SystemColors.Control;
-            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
-            dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.ControlLight;
-            dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
-            dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
-            dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
-            dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
-            dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
-            this.SongsTableView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
+            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;
             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);
@@ -276,6 +279,7 @@ namespace MusicPlayer
             this.viewToolStripMenuItem,
             this.playbackToolStripMenuItem,
             this.playlistToolStripMenuItem,
+            this.radioToolStripMenuItem,
             this.searchToolStripMenuItem,
             this.serverToolStripMenuItem});
             this.MenuStrip.Location = new System.Drawing.Point(0, 0);
@@ -693,6 +697,29 @@ 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
+            // 
+            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);
+            // 
             // MainForm
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -788,6 +815,9 @@ namespace MusicPlayer
         private System.Windows.Forms.ToolStripMenuItem serverToolStripMenuItem;
         private System.Windows.Forms.ToolStripMenuItem SelectServerJancoButton;
         private System.Windows.Forms.ToolStripMenuItem SelectServerYorickButton;
+        private System.Windows.Forms.ToolStripMenuItem radioToolStripMenuItem;
+        private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
+        private System.Windows.Forms.ToolStripMenuItem qDanceToolStripMenuItem;
     }
 }
 

+ 12 - 1
MusicPlayer/MusicPlayer/MainForm.cs

@@ -92,7 +92,8 @@ namespace MusicPlayer
                 PositionTrackBar.Value = Math.Max(main.audio.Position, 0);
 
             //Buffer display
-            BufferBar.Value = main.audio.Buffered / 10;
+            if(main.audio.Buffered / 10 > BufferBar.Minimum && main.audio.Buffered / 10 < BufferBar.Maximum)
+                BufferBar.Value = main.audio.Buffered / 10;
 
             //Time labels
             if (!clicked)
@@ -522,5 +523,15 @@ namespace MusicPlayer
         {
             main.SwitchServer("http://imegumii.nl");
         }
+
+        private void toolStripMenuItem2_Click(object sender, EventArgs e)
+        {
+            main.audio.Play(new RadioStation("538", main.api, "http://vip-icecast.538.lw.triple-it.nl:80/RADIO538_MP3"));
+        }
+
+        private void qDanceToolStripMenuItem_Click(object sender, EventArgs e)
+        {
+            main.audio.Play(new RadioStation("538", main.api, "            http://stream01.platform02.true.nl:8000/qdance-hard"));
+        }
     }
 }

+ 1 - 0
MusicPlayer/MusicPlayer/MusicPlayer.csproj

@@ -85,6 +85,7 @@
     </Compile>
     <Compile Include="Program.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="RadioStation.cs" />
     <Compile Include="Song.cs" />
     <Compile Include="SongsTable.cs">
       <SubType>Component</SubType>

+ 23 - 0
MusicPlayer/MusicPlayer/RadioStation.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MusicPlayer
+{
+    class RadioStation :Song
+    {
+        string radiourl;
+        public RadioStation(string name, APIHandler api, string url):base("-1", name,"","","",0,api)
+        {
+            radiourl = url;
+        }
+
+        protected override string GetURL()
+        {
+            return radiourl;
+        }
+
+    }
+}

+ 1 - 1
MusicPlayer/MusicPlayer/Song.cs

@@ -34,7 +34,7 @@ namespace MusicPlayer
             url = "";
         }
 
-        private string GetURL()
+        protected virtual string GetURL()
         {
             if (url == "")
             {