diff --git a/MusicPlayer/MusicPlayer/MainForm.Designer.cs b/MusicPlayer/MusicPlayer/MainForm.Designer.cs
index 844589c..1b07509 100644
--- a/MusicPlayer/MusicPlayer/MainForm.Designer.cs
+++ b/MusicPlayer/MusicPlayer/MainForm.Designer.cs
@@ -37,6 +37,9 @@
this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.playToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.ControlsPanel = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.SongsTableView)).BeginInit();
this.MainPanel.SuspendLayout();
this.MenuStrip.SuspendLayout();
@@ -58,7 +61,7 @@
this.SongsTableView.ReadOnly = true;
this.SongsTableView.RowHeadersVisible = false;
this.SongsTableView.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
- this.SongsTableView.Size = new System.Drawing.Size(760, 172);
+ this.SongsTableView.Size = new System.Drawing.Size(760, 148);
this.SongsTableView.TabIndex = 0;
//
// GenreListBox
@@ -92,20 +95,23 @@
//
// MainPanel
//
+ this.MainPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
this.MainPanel.Controls.Add(this.GenreListBox);
this.MainPanel.Controls.Add(this.ArtistListBox);
this.MainPanel.Controls.Add(this.AlbumListView);
this.MainPanel.Controls.Add(this.SongsTableView);
- this.MainPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.MainPanel.Location = new System.Drawing.Point(0, 24);
this.MainPanel.Name = "MainPanel";
- this.MainPanel.Size = new System.Drawing.Size(784, 337);
+ this.MainPanel.Size = new System.Drawing.Size(784, 313);
this.MainPanel.TabIndex = 5;
//
// MenuStrip
//
this.MenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.fileToolStripMenuItem});
+ this.fileToolStripMenuItem,
+ this.viewToolStripMenuItem});
this.MenuStrip.Location = new System.Drawing.Point(0, 0);
this.MenuStrip.Name = "MenuStrip";
this.MenuStrip.Size = new System.Drawing.Size(784, 24);
@@ -133,11 +139,36 @@
this.saveToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
this.saveToolStripMenuItem.Text = "Save";
//
+ // viewToolStripMenuItem
+ //
+ this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.playToolStripMenuItem});
+ this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
+ this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
+ this.viewToolStripMenuItem.Text = "View";
+ //
+ // playToolStripMenuItem
+ //
+ this.playToolStripMenuItem.Name = "playToolStripMenuItem";
+ this.playToolStripMenuItem.Size = new System.Drawing.Size(96, 22);
+ this.playToolStripMenuItem.Text = "Play";
+ this.playToolStripMenuItem.Click += new System.EventHandler(this.playToolStripMenuItem_Click);
+ //
+ // ControlsPanel
+ //
+ this.ControlsPanel.BackColor = System.Drawing.SystemColors.HotTrack;
+ this.ControlsPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
+ this.ControlsPanel.Location = new System.Drawing.Point(0, 343);
+ this.ControlsPanel.Name = "ControlsPanel";
+ this.ControlsPanel.Size = new System.Drawing.Size(784, 119);
+ this.ControlsPanel.TabIndex = 4;
+ //
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(784, 361);
+ this.ClientSize = new System.Drawing.Size(784, 462);
+ this.Controls.Add(this.ControlsPanel);
this.Controls.Add(this.MainPanel);
this.Controls.Add(this.MenuStrip);
this.MainMenuStrip = this.MenuStrip;
@@ -164,6 +195,9 @@
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem saveToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem playToolStripMenuItem;
+ private System.Windows.Forms.Panel ControlsPanel;
}
}
diff --git a/MusicPlayer/MusicPlayer/MainForm.cs b/MusicPlayer/MusicPlayer/MainForm.cs
index 522afb0..d4d88cd 100644
--- a/MusicPlayer/MusicPlayer/MainForm.cs
+++ b/MusicPlayer/MusicPlayer/MainForm.cs
@@ -1,10 +1,14 @@
-using System;
+using NAudio.Wave;
+using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
+using System.IO;
using System.Linq;
+using System.Net;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
@@ -50,5 +54,49 @@ namespace MusicPlayer
table.Add(new Song("Test Song 2", "Test Album 2", "Test Artist 2"));
}
+
+ private void playToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ PlayMp3FromUrl("http://imegumii.nl/music/English/Monstercat/Direct%20-%20Eternity.mp3");
+ }
+
+ private Stream ms = new MemoryStream();
+ public void PlayMp3FromUrl(string url)
+ {
+ new Thread(delegate (object o)
+ {
+ var response = WebRequest.Create(url).GetResponse();
+ using (var stream = response.GetResponseStream())
+ {
+ byte[] buffer = new byte[65536]; // 64KB chunks
+ int read;
+ while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)
+ {
+ var pos = ms.Position;
+ ms.Position = ms.Length;
+ ms.Write(buffer, 0, read);
+ ms.Position = pos;
+ }
+ }
+ }).Start();
+
+ // Pre-buffering some data to allow NAudio to start playing
+ while (ms.Length < 65536 * 10)
+ Thread.Sleep(1000);
+
+ ms.Position = 0;
+ using (WaveStream blockAlignedStream = new BlockAlignReductionStream(WaveFormatConversionStream.CreatePcmStream(new Mp3FileReader(ms))))
+ {
+ using (WaveOut waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()))
+ {
+ waveOut.Init(blockAlignedStream);
+ waveOut.Play();
+ while (waveOut.PlaybackState == PlaybackState.Playing)
+ {
+ System.Threading.Thread.Sleep(100);
+ }
+ }
+ }
+ }
}
}
diff --git a/MusicPlayer/MusicPlayer/MusicPlayer.csproj b/MusicPlayer/MusicPlayer/MusicPlayer.csproj
index bd6a732..d816bbe 100644
--- a/MusicPlayer/MusicPlayer/MusicPlayer.csproj
+++ b/MusicPlayer/MusicPlayer/MusicPlayer.csproj
@@ -1,4 +1,4 @@
-
+
@@ -33,6 +33,10 @@
4
+
+ ..\packages\NAudio.1.7.3\lib\net35\NAudio.dll
+ True
+
@@ -46,7 +50,7 @@
-
+
Form
@@ -74,6 +78,7 @@
True
Resources.resx
+
SettingsSingleFileGenerator
Settings.Designer.cs
@@ -95,4 +100,4 @@
-->
-
+
\ No newline at end of file
diff --git a/MusicPlayer/MusicPlayer/packages.config b/MusicPlayer/MusicPlayer/packages.config
index 64b5d8e..79cd541 100644
--- a/MusicPlayer/MusicPlayer/packages.config
+++ b/MusicPlayer/MusicPlayer/packages.config
@@ -1,4 +1,5 @@
+
\ No newline at end of file