Change to public. New Structure.

This commit is contained in:
2015-10-29 21:21:35 +01:00
parent f79b2ace28
commit ada4321bca
9 changed files with 63 additions and 48 deletions
+1 -2
View File
@@ -8,7 +8,7 @@ using Newtonsoft.Json.Linq;
namespace MusicPlayer namespace MusicPlayer
{ {
internal class APIHandler public class APIHandler
{ {
private NetworkHandler nw; private NetworkHandler nw;
@@ -24,7 +24,6 @@ namespace MusicPlayer
return o["songurl"].ToString(); return o["songurl"].ToString();
} }
return o["errormsg"].ToString(); return o["errormsg"].ToString();
} }
public List<Artist> GetArtists() public List<Artist> GetArtists()
+1 -1
View File
@@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace MusicPlayer namespace MusicPlayer
{ {
class AudioHandler public class AudioHandler
{ {
public static Stream ms = new MemoryStream(); public static Stream ms = new MemoryStream();
+28 -6
View File
@@ -6,24 +6,46 @@ using System.Threading.Tasks;
namespace MusicPlayer namespace MusicPlayer
{ {
class Main public class Main
{ {
private APIHandler api; public APIHandler api;
private MainForm form; public MainForm form;
private NetworkHandler nw; public NetworkHandler nw;
private AudioHandler audio; public AudioHandler audio;
private SongsTable table;
public Main(NetworkHandler nw, APIHandler api, MainForm form) public Main(NetworkHandler nw, APIHandler api, MainForm form)
{ {
this.nw = nw; this.nw = nw;
this.api = api; this.api = api;
this.form = form; this.form = form;
form.main = this;
audio = new AudioHandler(); audio = new AudioHandler();
table = new SongsTable();
form.SongsTableView.DataSource = table;
Console.WriteLine(api.GetSongURLByID("102")); Populate();
} }
private void Populate()
{
table.Add(new Song("102", "Test Song 1", "Test Album 1", "Test Artist 1", api));
form.GenreListBox.Items.Add("Hardcore");
form.GenreListBox.Items.Add("Hardstyle");
form.GenreListBox.Items.Add("Pop");
form.ArtistListBox.Items.Add("Kygo");
form.ArtistListBox.Items.Add("Monstercat");
form.ArtistListBox.Items.Add("Mozart");
form.AlbumListView.Items.Add("Album 1");
form.AlbumListView.Items.Add("Album 2");
form.AlbumListView.Items.Add("Album 3");
table.Add(new Song("104", "Test Song 2", "Test Album 2", "Test Artist 2", api));
}
} }
} }
+7 -4
View File
@@ -64,8 +64,10 @@
this.SongsTableView.ReadOnly = true; this.SongsTableView.ReadOnly = true;
this.SongsTableView.RowHeadersVisible = false; this.SongsTableView.RowHeadersVisible = false;
this.SongsTableView.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.SongsTableView.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.SongsTableView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.SongsTableView.Size = new System.Drawing.Size(760, 148); this.SongsTableView.Size = new System.Drawing.Size(760, 148);
this.SongsTableView.TabIndex = 0; this.SongsTableView.TabIndex = 0;
this.SongsTableView.SelectionChanged += new System.EventHandler(this.SongsTableView_SelectionChanged);
// //
// GenreListBox // GenreListBox
// //
@@ -186,6 +188,7 @@
this.MinimumSize = new System.Drawing.Size(800, 500); this.MinimumSize = new System.Drawing.Size(800, 500);
this.Name = "MainForm"; this.Name = "MainForm";
this.Text = "YJMPD Music Player"; this.Text = "YJMPD Music Player";
this.Load += new System.EventHandler(this.MainForm_Load);
((System.ComponentModel.ISupportInitialize)(this.SongsTableView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.SongsTableView)).EndInit();
this.MainPanel.ResumeLayout(false); this.MainPanel.ResumeLayout(false);
this.MenuStrip.ResumeLayout(false); this.MenuStrip.ResumeLayout(false);
@@ -198,10 +201,10 @@
#endregion #endregion
private System.Windows.Forms.DataGridView SongsTableView; public System.Windows.Forms.DataGridView SongsTableView;
private System.Windows.Forms.ListBox GenreListBox; public System.Windows.Forms.ListBox GenreListBox;
private System.Windows.Forms.ListView AlbumListView; public System.Windows.Forms.ListView AlbumListView;
private System.Windows.Forms.ListBox ArtistListBox; public System.Windows.Forms.ListBox ArtistListBox;
private System.Windows.Forms.Panel MainPanel; private System.Windows.Forms.Panel MainPanel;
private System.Windows.Forms.MenuStrip MenuStrip; private System.Windows.Forms.MenuStrip MenuStrip;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
+11 -28
View File
@@ -17,46 +17,29 @@ namespace MusicPlayer
{ {
public partial class MainForm : Form public partial class MainForm : Form
{ {
private SongsTable table; public Main main
{
get; set;
}
public MainForm() public MainForm()
{ {
InitializeComponent(); InitializeComponent();
} }
private void Form1_Load(object sender, EventArgs e) private void MainForm_Load(object sender, EventArgs e)
{ {
//APIHandler api = new APIHandler();
//NetworkHandler nw = new NetworkHandler("83.128.250.123", api);
table = new SongsTable();
SongsTableView.DataSource = table;
Populate();
}
private void Populate()
{
table.Add(new Song("Test Song 1", "Test Album 1", "Test Artist 1"));
GenreListBox.Items.Add("Hardcore");
GenreListBox.Items.Add("Hardstyle");
GenreListBox.Items.Add("Pop");
ArtistListBox.Items.Add("Kygo");
ArtistListBox.Items.Add("Monstercat");
ArtistListBox.Items.Add("Mozart");
AlbumListView.Items.Add("Album 1");
AlbumListView.Items.Add("Album 2");
AlbumListView.Items.Add("Album 3");
table.Add(new Song("Test Song 2", "Test Album 2", "Test Artist 2"));
} }
private void PlayButton_Click(object sender, EventArgs e) private void PlayButton_Click(object sender, EventArgs e)
{ {
AudioHandler.PlayMp3FromUrl("http://imegumii.nl/music/English/Monstercat/Direct%20-%20Eternity.mp3"); AudioHandler.PlayMp3FromUrl("http://imegumii.nl/music/English/Monstercat/Direct%20-%20Eternity.mp3");
} }
private void SongsTableView_SelectionChanged(object sender, EventArgs e)
{
DataGridViewSelectedRowCollection col = SongsTableView.SelectedRows;
}
} }
} }
+2 -1
View File
@@ -35,7 +35,7 @@
<ItemGroup> <ItemGroup>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath> <HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="NAudio, Version=1.7.3.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="NAudio, Version=1.7.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NAudio.1.7.3\lib\net35\NAudio.dll</HintPath> <HintPath>..\packages\NAudio.1.7.3\lib\net35\NAudio.dll</HintPath>
@@ -55,6 +55,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AudioHandler.cs" /> <Compile Include="AudioHandler.cs" />
<Compile Include="Main.cs" />
<Compile Include="MainForm.cs"> <Compile Include="MainForm.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
+1 -1
View File
@@ -9,7 +9,7 @@ using Newtonsoft.Json.Linq;
namespace MusicPlayer namespace MusicPlayer
{ {
class NetworkHandler public class NetworkHandler
{ {
private int port = 8585; private int port = 8585;
private string ip; private string ip;
+3 -3
View File
@@ -14,14 +14,14 @@ namespace MusicPlayer
[STAThread] [STAThread]
static void Main() static void Main()
{ {
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
NetworkHandler nw = new NetworkHandler("http://www.imegumii.nl"); NetworkHandler nw = new NetworkHandler("http://www.imegumii.nl");
APIHandler api = new APIHandler(nw); APIHandler api = new APIHandler(nw);
MainForm form = new MainForm(); MainForm form = new MainForm();
new Main(nw, api, form); new Main(nw, api, form);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(form); Application.Run(form);
} }
} }
+9 -2
View File
@@ -8,18 +8,25 @@ namespace MusicPlayer
{ {
class Song class Song
{ {
public string SongID { get; set; }
public string Name { get; set; } public string Name { get; set; }
public string Album { get; set; } public string Album { get; set; }
public string Artist { get; set; } public string Artist { get; set; }
public string Url { get { return GetURL(); } set { SetURL(value); } } public string Url { get { return GetURL(); } set { SetURL(value); } }
private APIHandler api;
private string url; private string url;
public Song(string name, string album, string artist) public Song(string songid, string name, string album, string artist, APIHandler api)
{ {
SongID = songid;
Name = name; Name = name;
Album = album; Album = album;
Artist = artist; Artist = artist;
this.api = api;
url = ""; url = "";
} }
@@ -27,7 +34,7 @@ namespace MusicPlayer
{ {
if (url == "") if (url == "")
{ {
url = "http://imegumii.nl/music/Old%20Music/Pre-Parade%20-%20Toradora.mp3"; url = api.GetSongURLByID(SongID);
} }
return url; return url;