Forráskód Böngészése

Better naming and buffering

Kenneth van Ewijk 10 éve
szülő
commit
90f35de242

+ 9 - 6
MusicPlayer/MusicPlayer/AudioHandler.cs

@@ -191,7 +191,14 @@ namespace MusicPlayer
         private void PlayAudio()
         {
             AState = AudioState.WAITING;
-            while (ms.Length < 32768 * 5 && BState != BufferState.DONE)
+
+            int buffertime = 0;
+            if (CurrentSong is RadioStation)
+                buffertime = 32768 * 10;
+            else
+                buffertime = 65536 * 10;
+
+            while (ms.Length < buffertime && BState != BufferState.DONE)
                 Thread.Sleep(1000);
             AState = AudioState.PLAYING;
 
@@ -222,11 +229,7 @@ namespace MusicPlayer
             LengthBuffer = response.ContentLength;
             using (var stream = response.GetResponseStream())
             {
-                byte[] buffer;
-                if (CurrentSong is RadioStation)
-                   buffer  = new byte[32768]; // 32KB chunks
-                else
-                   buffer = new byte[65536]; // 32KB chunks
+                byte[] buffer = new byte[65536]; // 32KB chunks
 
                 int read;
                 BState = BufferState.BUFFERING;

+ 11 - 11
MusicPlayer/MusicPlayer/MainForm.Designer.cs

@@ -52,7 +52,7 @@ namespace MusicPlayer
             this.overviewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.playlistsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
-            this.ViewCurrentPlaylistButton = new System.Windows.Forms.ToolStripMenuItem();
+            this.ViewQueueButton = new System.Windows.Forms.ToolStripMenuItem();
             this.playbackToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
             this.PlayNextSongButton = new System.Windows.Forms.ToolStripMenuItem();
             this.LoopSongButton = new System.Windows.Forms.ToolStripMenuItem();
@@ -321,7 +321,7 @@ namespace MusicPlayer
             this.overviewToolStripMenuItem,
             this.playlistsToolStripMenuItem,
             this.toolStripSeparator4,
-            this.ViewCurrentPlaylistButton});
+            this.ViewQueueButton});
             this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
             this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
             this.viewToolStripMenuItem.Text = "View";
@@ -329,28 +329,28 @@ namespace MusicPlayer
             // overviewToolStripMenuItem
             // 
             this.overviewToolStripMenuItem.Name = "overviewToolStripMenuItem";
-            this.overviewToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
+            this.overviewToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
             this.overviewToolStripMenuItem.Text = "Overview";
             this.overviewToolStripMenuItem.Click += new System.EventHandler(this.overviewToolStripMenuItem_Click);
             // 
             // playlistsToolStripMenuItem
             // 
             this.playlistsToolStripMenuItem.Name = "playlistsToolStripMenuItem";
-            this.playlistsToolStripMenuItem.Size = new System.Drawing.Size(154, 22);
+            this.playlistsToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
             this.playlistsToolStripMenuItem.Text = "Playlists";
             this.playlistsToolStripMenuItem.Click += new System.EventHandler(this.playlistsToolStripMenuItem_Click);
             // 
             // toolStripSeparator4
             // 
             this.toolStripSeparator4.Name = "toolStripSeparator4";
-            this.toolStripSeparator4.Size = new System.Drawing.Size(151, 6);
+            this.toolStripSeparator4.Size = new System.Drawing.Size(149, 6);
             // 
-            // ViewCurrentPlaylistButton
+            // ViewQueueButton
             // 
-            this.ViewCurrentPlaylistButton.Name = "ViewCurrentPlaylistButton";
-            this.ViewCurrentPlaylistButton.Size = new System.Drawing.Size(154, 22);
-            this.ViewCurrentPlaylistButton.Text = "Current Playlist";
-            this.ViewCurrentPlaylistButton.Click += new System.EventHandler(this.ViewCurrentPlaylistButton_Click);
+            this.ViewQueueButton.Name = "ViewQueueButton";
+            this.ViewQueueButton.Size = new System.Drawing.Size(152, 22);
+            this.ViewQueueButton.Text = "Queue";
+            this.ViewQueueButton.Click += new System.EventHandler(this.ViewCurrentPlaylistButton_Click);
             // 
             // playbackToolStripMenuItem
             // 
@@ -861,7 +861,7 @@ namespace MusicPlayer
         private System.Windows.Forms.ToolStripMenuItem NotifyMenuStripNextButton;
         private System.Windows.Forms.ToolStripMenuItem NotifyMenuStripPreviousButton;
         private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
-        private System.Windows.Forms.ToolStripMenuItem ViewCurrentPlaylistButton;
+        private System.Windows.Forms.ToolStripMenuItem ViewQueueButton;
         private System.Windows.Forms.ToolStripMenuItem serverToolStripMenuItem;
         private System.Windows.Forms.ToolStripMenuItem SelectServerJancoButton;
         private System.Windows.Forms.ToolStripMenuItem SelectServerYorickButton;