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
{
internal class APIHandler
public class APIHandler
{
private NetworkHandler nw;
@@ -24,7 +24,6 @@ namespace MusicPlayer
return o["songurl"].ToString();
}
return o["errormsg"].ToString();
}
public List<Artist> GetArtists()
+1 -1
View File
@@ -10,7 +10,7 @@ using System.Threading.Tasks;
namespace MusicPlayer
{
class AudioHandler
public class AudioHandler
{
public static Stream ms = new MemoryStream();
+28 -6
View File
@@ -6,24 +6,46 @@ using System.Threading.Tasks;
namespace MusicPlayer
{
class Main
public class Main
{
private APIHandler api;
private MainForm form;
private NetworkHandler nw;
private AudioHandler audio;
public APIHandler api;
public MainForm form;
public NetworkHandler nw;
public AudioHandler audio;
private SongsTable table;
public Main(NetworkHandler nw, APIHandler api, MainForm form)
{
this.nw = nw;
this.api = api;
this.form = form;
form.main = this;
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.RowHeadersVisible = false;
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.TabIndex = 0;
this.SongsTableView.SelectionChanged += new System.EventHandler(this.SongsTableView_SelectionChanged);
//
// GenreListBox
//
@@ -186,6 +188,7 @@
this.MinimumSize = new System.Drawing.Size(800, 500);
this.Name = "MainForm";
this.Text = "YJMPD Music Player";
this.Load += new System.EventHandler(this.MainForm_Load);
((System.ComponentModel.ISupportInitialize)(this.SongsTableView)).EndInit();
this.MainPanel.ResumeLayout(false);
this.MenuStrip.ResumeLayout(false);
@@ -198,10 +201,10 @@
#endregion
private System.Windows.Forms.DataGridView SongsTableView;
private System.Windows.Forms.ListBox GenreListBox;
private System.Windows.Forms.ListView AlbumListView;
private System.Windows.Forms.ListBox ArtistListBox;
public System.Windows.Forms.DataGridView SongsTableView;
public System.Windows.Forms.ListBox GenreListBox;
public System.Windows.Forms.ListView AlbumListView;
public System.Windows.Forms.ListBox ArtistListBox;
private System.Windows.Forms.Panel MainPanel;
private System.Windows.Forms.MenuStrip MenuStrip;
private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
+11 -28
View File
@@ -17,46 +17,29 @@ namespace MusicPlayer
{
public partial class MainForm : Form
{
private SongsTable table;
public Main main
{
get; set;
}
public MainForm()
{
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)
{
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>
<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>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="NAudio, Version=1.7.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NAudio.1.7.3\lib\net35\NAudio.dll</HintPath>
@@ -55,6 +55,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AudioHandler.cs" />
<Compile Include="Main.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
+1 -1
View File
@@ -9,7 +9,7 @@ using Newtonsoft.Json.Linq;
namespace MusicPlayer
{
class NetworkHandler
public class NetworkHandler
{
private int port = 8585;
private string ip;
+3 -3
View File
@@ -14,14 +14,14 @@ namespace MusicPlayer
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
NetworkHandler nw = new NetworkHandler("http://www.imegumii.nl");
APIHandler api = new APIHandler(nw);
MainForm form = new MainForm();
new Main(nw, api, form);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(form);
}
}
+9 -2
View File
@@ -8,18 +8,25 @@ namespace MusicPlayer
{
class Song
{
public string SongID { get; set; }
public string Name { get; set; }
public string Album { get; set; }
public string Artist { get; set; }
public string Url { get { return GetURL(); } set { SetURL(value); } }
private APIHandler api;
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;
Album = album;
Artist = artist;
this.api = api;
url = "";
}
@@ -27,7 +34,7 @@ namespace MusicPlayer
{
if (url == "")
{
url = "http://imegumii.nl/music/Old%20Music/Pre-Parade%20-%20Toradora.mp3";
url = api.GetSongURLByID(SongID);
}
return url;