Merge remote-tracking branch 'origin/gui' into developer

This commit is contained in:
Yorick Rommers
2015-10-30 19:41:53 +01:00
31 changed files with 1663 additions and 113 deletions
Regular → Executable
View File
Regular → Executable
View File
Regular → Executable
View File
+15 -1
View File
@@ -71,7 +71,7 @@ namespace MusicPlayer
dynamic songs = o["songs"];
for (int i = 0; i < songs.Count; i++)
{
songslist.Add(new Song(songs[i][0].ToString(), songs[i][3].ToString(), songs[i][5].ToString(), songs[i][4].ToString(), this));
songslist.Add(new Song(songs[i][0].ToString(), songs[i][3].ToString(), songs[i][5].ToString(), songs[i][4].ToString(), songs[i][1].ToString(), (int)songs[i][9], this));
}
}
return songslist;
@@ -120,5 +120,19 @@ namespace MusicPlayer
}
return yearlist;
}
public List<Genre> GetGenres()
{
List<Genre> genreslist = new List<Genre>();
JObject o = nw.SendString("getgenres?id=hallo");
if (o["result"].ToString() == "OK")
{
for (int i = 0; i < o["genres"].Count(); i++)
{
genreslist.Add(new Genre(o["genres"][i][0].ToString()));
}
}
return genreslist;
}
}
}
Regular → Executable
View File
View File
View File
+203 -39
View File
@@ -12,47 +12,211 @@ namespace MusicPlayer
{
public class AudioHandler
{
public static Stream ms = new MemoryStream();
public enum AudioState { PLAYING, WAITING, STOPPED, PAUSED, SEEKING }
public enum BufferState { EMPTY, BUFFERING, DONE }
public AudioState AState { get; set; }
public BufferState BState { get; set; }
public static void PlayMp3FromUrl(string url)
public int Buffered { get { return Math.Min((int)((bufpos / (double)LengthBuffer) * 100), 100); } }
private long LengthBuffer { get; set; }
private long bufpos = 0;
public int Position { get { return Math.Min((int)((playpos / (double)Length) * 100), 100); } }
private long Length { get; set; }
private long playpos = 0;
public int CurrentTime { get; set; }
public int TotalTime { get { return CurrentSong != null ? CurrentSong.Seconds : 0; } }
private long seek = 0;
private Stream ms;
private Thread network;
private Thread audio;
private Song CurrentSong;
public AudioHandler()
{
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();
new Thread(delegate (object o)
{
// 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);
}
}
}
}).Start();
CreateThreads();
}
private void CreateThreads()
{
AState = AudioState.STOPPED;
BState = BufferState.EMPTY;
CurrentSong = null;
Thread.Sleep(11);
ms = new MemoryStream();
network = new Thread(LoadAudio);
audio = new Thread(PlayAudio);
network.IsBackground = true;
audio.IsBackground = true;
Length = 1;
LengthBuffer = 1;
bufpos = 0;
playpos = 0;
CurrentTime = 0;
}
public void Play(Song s)
{
if (CurrentSong == s && AState == AudioState.PAUSED)
AState = AudioState.PLAYING;
else
{
Stop();
CurrentSong = s;
network.Start(s);
audio.Start();
}
}
public void Seek(int position)
{
if (position >= Buffered-1)
return;
seek = Length / 100 * position;
AState = AudioState.SEEKING;
}
public void Stop()
{
CreateThreads();
}
public void Pause()
{
AState = AudioState.PAUSED;
}
private void StreamFromMP3(Stream s, long pos, bool firstrun)
{
long position = 0;
ms.Position = position;
Mp3FileReader mp3fr = new Mp3FileReader(ms);
using (WaveStream blockAlignedStream = new BlockAlignReductionStream(WaveFormatConversionStream.CreatePcmStream(mp3fr)))
{
blockAlignedStream.Position = pos;
using (WaveOut waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()))
{
waveOut.Init(blockAlignedStream);
waveOut.Play();
Length = CurrentSong.Seconds * waveOut.OutputWaveFormat.AverageBytesPerSecond;
CurrentTime = (int)(ms.Position / waveOut.OutputWaveFormat.AverageBytesPerSecond);
while (waveOut.PlaybackState != PlaybackState.Stopped)
{
System.Threading.Thread.Sleep(10);
if (AState == AudioState.PLAYING && waveOut.PlaybackState == PlaybackState.Paused)
{
blockAlignedStream.Position = position;
waveOut.Play();
}
if (AState == AudioState.PAUSED && waveOut.PlaybackState == PlaybackState.Playing)
{
position = blockAlignedStream.Position;
waveOut.Pause();
}
if (AState == AudioState.SEEKING)
{
blockAlignedStream.Seek(seek - (seek % blockAlignedStream.WaveFormat.BlockAlign), SeekOrigin.Begin);
AState = AudioState.PLAYING;
//waveOut.Play();
}
if (AState == AudioState.STOPPED)
{
waveOut.Stop();
}
if (BState == BufferState.DONE && firstrun )
{
position = mp3fr.Position;
mp3fr.Close();
StreamFromMP3(ms,position, false);
break;
}
playpos = blockAlignedStream.Position;
CurrentTime = (int)(playpos / waveOut.OutputWaveFormat.AverageBytesPerSecond);
}
AState = AudioState.STOPPED;
playpos = 0;
CurrentTime = 0;
}
}
}
private void PlayAudio()
{
AState = AudioState.WAITING;
while (ms.Length < 65536 * 10 && BState != BufferState.DONE)
Thread.Sleep(1000);
AState = AudioState.PLAYING;
StreamFromMP3(ms,0, true);
}
private void LoadAudio(object o)
{
Song s = (Song) o;
WebResponse response = null;
try
{
response = WebRequest.Create(s.Url).GetResponse();
}
catch(Exception e)
{
BState = BufferState.EMPTY;
AState = AudioState.STOPPED;
return;
}
BState = BufferState.EMPTY;
LengthBuffer = response.ContentLength;
using (var stream = response.GetResponseStream())
{
//byte[] buffer = new byte[65536]; // 64KB chunks
byte[] buffer = new byte[65536*4]; // 256KB chunks
int read;
BState = BufferState.BUFFERING;
AState = AudioState.WAITING;
while ((read = stream.Read(buffer, 0, buffer.Length)) > 0 && AState != AudioState.STOPPED)
{
var pos = ms.Position;
ms.Position = ms.Length;
ms.Write(buffer, 0, read);
ms.Position = pos;
this.bufpos = ms.Length;
}
}
BState = BufferState.DONE;
}
}
}
Generated Regular → Executable
View File
View File
+11
View File
@@ -0,0 +1,11 @@
namespace MusicPlayer
{
public class Genre
{
public string name { get; set; }
public Genre(string name)
{
this.name = name;
}
}
}
Regular → Executable
+31 -13
View File
@@ -25,27 +25,45 @@ namespace MusicPlayer
audio = new AudioHandler();
table = new SongsTable();
form.SongsTableView.DataSource = table;
form.SongsTableView.Columns[4].Visible = false;
Populate();
}
private void Populate()
{
table.Add(new Song("102", "Test Song 1", "Test Album 1", "Test Artist 1", api));
this.api.GetAlbums().ForEach(a => form.AlbumListView.Items.Add(a.albumnaam));
this.api.GetArtists().ForEach(a => form.ArtistListBox.Items.Add(a.naam));
this.api.GetGenres().ForEach(g => form.GenreListBox.Items.Add(g.name));
}
form.GenreListBox.Items.Add("Hardcore");
form.GenreListBox.Items.Add("Hardstyle");
form.GenreListBox.Items.Add("Pop");
public void ArtistFilter(string artist)
{
table.Clear();
api.GetSongsByArtist(artist).ForEach(s =>
{
table.Add(s);
});
}
form.ArtistListBox.Items.Add("Kygo");
form.ArtistListBox.Items.Add("Monstercat");
form.ArtistListBox.Items.Add("Mozart");
public void GenreFilter(string genre)
{
table.Clear();
api.GetSongsByGenre(genre).ForEach(s =>
{
table.Add(s);
});
}
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));
public void AlbumFilter(string album)
{
table.Clear();
api.GetSongsByAlbum(album).ForEach(s =>
{
table.Add(s);
});
}
}
}
+166 -4
View File
@@ -21,13 +21,14 @@
}
#region Windows Form Designer generated code
bool clicked = false;
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.SongsTableView = new System.Windows.Forms.DataGridView();
this.GenreListBox = new System.Windows.Forms.ListBox();
@@ -40,11 +41,26 @@
this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.viewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ControlsPanel = new System.Windows.Forms.Panel();
this.LabelTotalTime = new System.Windows.Forms.Label();
this.LabelCurrentTime = new System.Windows.Forms.Label();
this.PositionTrackBar = new System.Windows.Forms.TrackBar();
this.PositionLabel = new System.Windows.Forms.Label();
this.BufferLabel = new System.Windows.Forms.Label();
this.PositionBar = new System.Windows.Forms.ProgressBar();
this.BufferBar = new System.Windows.Forms.ProgressBar();
this.StopButton = new System.Windows.Forms.Button();
this.PauseButton = new System.Windows.Forms.Button();
this.PlayButton = new System.Windows.Forms.Button();
this.UpdateTimer = new System.Windows.Forms.Timer(this.components);
this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
this.playlistsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.overviewToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.PlaylistBox = new System.Windows.Forms.ListBox();
((System.ComponentModel.ISupportInitialize)(this.SongsTableView)).BeginInit();
this.MainPanel.SuspendLayout();
this.MenuStrip.SuspendLayout();
this.ControlsPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.PositionTrackBar)).BeginInit();
this.SuspendLayout();
//
// SongsTableView
@@ -67,7 +83,7 @@
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);
this.SongsTableView.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.SongsTableView_CellDoubleClick);
//
// GenreListBox
//
@@ -78,6 +94,7 @@
this.GenreListBox.Size = new System.Drawing.Size(124, 134);
this.GenreListBox.Sorted = true;
this.GenreListBox.TabIndex = 1;
this.GenreListBox.SelectedIndexChanged += new System.EventHandler(this.GenreListBox_SelectedIndexChanged);
//
// AlbumListView
//
@@ -90,6 +107,7 @@
this.AlbumListView.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.AlbumListView.TabIndex = 2;
this.AlbumListView.UseCompatibleStateImageBehavior = false;
this.AlbumListView.SelectedIndexChanged += new System.EventHandler(this.AlbumListView_SelectedIndexChanged);
//
// ArtistListBox
//
@@ -100,6 +118,7 @@
this.ArtistListBox.Size = new System.Drawing.Size(124, 134);
this.ArtistListBox.Sorted = true;
this.ArtistListBox.TabIndex = 3;
this.ArtistListBox.SelectedIndexChanged += new System.EventHandler(this.ArtistListBox_SelectedIndexChanged);
//
// MainPanel
//
@@ -107,6 +126,7 @@
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.MainPanel.BackColor = System.Drawing.SystemColors.Window;
this.MainPanel.Controls.Add(this.PlaylistBox);
this.MainPanel.Controls.Add(this.GenreListBox);
this.MainPanel.Controls.Add(this.ArtistListBox);
this.MainPanel.Controls.Add(this.AlbumListView);
@@ -140,17 +160,20 @@
// openToolStripMenuItem
//
this.openToolStripMenuItem.Name = "openToolStripMenuItem";
this.openToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
this.openToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.openToolStripMenuItem.Text = "Open";
//
// saveToolStripMenuItem
//
this.saveToolStripMenuItem.Name = "saveToolStripMenuItem";
this.saveToolStripMenuItem.Size = new System.Drawing.Size(103, 22);
this.saveToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.saveToolStripMenuItem.Text = "Save";
//
// viewToolStripMenuItem
//
this.viewToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.playlistsToolStripMenuItem,
this.overviewToolStripMenuItem});
this.viewToolStripMenuItem.Name = "viewToolStripMenuItem";
this.viewToolStripMenuItem.Size = new System.Drawing.Size(44, 20);
this.viewToolStripMenuItem.Text = "View";
@@ -158,6 +181,15 @@
// ControlsPanel
//
this.ControlsPanel.BackColor = System.Drawing.SystemColors.WindowFrame;
this.ControlsPanel.Controls.Add(this.LabelTotalTime);
this.ControlsPanel.Controls.Add(this.LabelCurrentTime);
this.ControlsPanel.Controls.Add(this.PositionTrackBar);
this.ControlsPanel.Controls.Add(this.PositionLabel);
this.ControlsPanel.Controls.Add(this.BufferLabel);
this.ControlsPanel.Controls.Add(this.PositionBar);
this.ControlsPanel.Controls.Add(this.BufferBar);
this.ControlsPanel.Controls.Add(this.StopButton);
this.ControlsPanel.Controls.Add(this.PauseButton);
this.ControlsPanel.Controls.Add(this.PlayButton);
this.ControlsPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.ControlsPanel.Location = new System.Drawing.Point(0, 343);
@@ -165,6 +197,85 @@
this.ControlsPanel.Size = new System.Drawing.Size(784, 119);
this.ControlsPanel.TabIndex = 4;
//
// LabelTotalTime
//
this.LabelTotalTime.AutoSize = true;
this.LabelTotalTime.Location = new System.Drawing.Point(693, 60);
this.LabelTotalTime.Name = "LabelTotalTime";
this.LabelTotalTime.Size = new System.Drawing.Size(49, 13);
this.LabelTotalTime.TabIndex = 9;
this.LabelTotalTime.Text = "00:00:00";
//
// LabelCurrentTime
//
this.LabelCurrentTime.AutoSize = true;
this.LabelCurrentTime.Location = new System.Drawing.Point(358, 60);
this.LabelCurrentTime.Name = "LabelCurrentTime";
this.LabelCurrentTime.Size = new System.Drawing.Size(49, 13);
this.LabelCurrentTime.TabIndex = 8;
this.LabelCurrentTime.Text = "00:00:00";
//
// PositionTrackBar
//
this.PositionTrackBar.Enabled = false;
this.PositionTrackBar.Location = new System.Drawing.Point(346, 13);
this.PositionTrackBar.Maximum = 100;
this.PositionTrackBar.Name = "PositionTrackBar";
this.PositionTrackBar.Size = new System.Drawing.Size(426, 45);
this.PositionTrackBar.TabIndex = 7;
//
// PositionLabel
//
this.PositionLabel.AutoSize = true;
this.PositionLabel.Location = new System.Drawing.Point(285, 90);
this.PositionLabel.Name = "PositionLabel";
this.PositionLabel.Size = new System.Drawing.Size(44, 13);
this.PositionLabel.TabIndex = 6;
this.PositionLabel.Text = "Position";
//
// BufferLabel
//
this.BufferLabel.AutoSize = true;
this.BufferLabel.Location = new System.Drawing.Point(285, 60);
this.BufferLabel.Name = "BufferLabel";
this.BufferLabel.Size = new System.Drawing.Size(35, 13);
this.BufferLabel.TabIndex = 5;
this.BufferLabel.Text = "Buffer";
//
// PositionBar
//
this.PositionBar.Location = new System.Drawing.Point(13, 90);
this.PositionBar.Name = "PositionBar";
this.PositionBar.Size = new System.Drawing.Size(265, 23);
this.PositionBar.TabIndex = 4;
//
// BufferBar
//
this.BufferBar.Location = new System.Drawing.Point(13, 60);
this.BufferBar.Name = "BufferBar";
this.BufferBar.Size = new System.Drawing.Size(265, 23);
this.BufferBar.TabIndex = 3;
//
// StopButton
//
this.StopButton.Location = new System.Drawing.Point(203, 13);
this.StopButton.Name = "StopButton";
this.StopButton.Size = new System.Drawing.Size(75, 23);
this.StopButton.TabIndex = 2;
this.StopButton.Text = "Stop";
this.StopButton.UseVisualStyleBackColor = true;
this.StopButton.Click += new System.EventHandler(this.StopButton_Click);
//
// PauseButton
//
this.PauseButton.Location = new System.Drawing.Point(108, 13);
this.PauseButton.Name = "PauseButton";
this.PauseButton.Size = new System.Drawing.Size(75, 23);
this.PauseButton.TabIndex = 1;
this.PauseButton.Text = "Pause";
this.PauseButton.UseVisualStyleBackColor = true;
this.PauseButton.Click += new System.EventHandler(this.PauseButton_Click);
//
// PlayButton
//
this.PlayButton.Location = new System.Drawing.Point(12, 13);
@@ -175,6 +286,41 @@
this.PlayButton.UseVisualStyleBackColor = true;
this.PlayButton.Click += new System.EventHandler(this.PlayButton_Click);
//
// UpdateTimer
//
this.UpdateTimer.Interval = 150;
this.UpdateTimer.Tick += new System.EventHandler(this.UpdateTimer_Tick);
//
// notifyIcon1
//
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
this.notifyIcon1.Text = "notifyIcon1";
this.notifyIcon1.Visible = true;
this.notifyIcon1.Click += new System.EventHandler(this.notifyIcon1_Click);
//
// playlistsToolStripMenuItem
//
this.playlistsToolStripMenuItem.Name = "playlistsToolStripMenuItem";
this.playlistsToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.playlistsToolStripMenuItem.Text = "Playlists";
this.playlistsToolStripMenuItem.Click += new System.EventHandler(this.playlistsToolStripMenuItem_Click);
//
// overviewToolStripMenuItem
//
this.overviewToolStripMenuItem.Name = "overviewToolStripMenuItem";
this.overviewToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.overviewToolStripMenuItem.Text = "Overview";
this.overviewToolStripMenuItem.Click += new System.EventHandler(this.overviewToolStripMenuItem_Click);
//
// PlaylistBox
//
this.PlaylistBox.FormattingEnabled = true;
this.PlaylistBox.Location = new System.Drawing.Point(12, 12);
this.PlaylistBox.Name = "PlaylistBox";
this.PlaylistBox.Size = new System.Drawing.Size(377, 134);
this.PlaylistBox.TabIndex = 4;
this.PlaylistBox.Visible = false;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -194,6 +340,8 @@
this.MenuStrip.ResumeLayout(false);
this.MenuStrip.PerformLayout();
this.ControlsPanel.ResumeLayout(false);
this.ControlsPanel.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.PositionTrackBar)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -213,6 +361,20 @@
private System.Windows.Forms.ToolStripMenuItem viewToolStripMenuItem;
private System.Windows.Forms.Panel ControlsPanel;
private System.Windows.Forms.Button PlayButton;
private System.Windows.Forms.Button StopButton;
private System.Windows.Forms.Button PauseButton;
private System.Windows.Forms.Label PositionLabel;
private System.Windows.Forms.Label BufferLabel;
private System.Windows.Forms.ProgressBar PositionBar;
private System.Windows.Forms.ProgressBar BufferBar;
private System.Windows.Forms.Timer UpdateTimer;
private System.Windows.Forms.TrackBar PositionTrackBar;
private System.Windows.Forms.Label LabelTotalTime;
private System.Windows.Forms.Label LabelCurrentTime;
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ToolStripMenuItem playlistsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem overviewToolStripMenuItem;
private System.Windows.Forms.ListBox PlaylistBox;
}
}
+110 -4
View File
@@ -17,6 +17,7 @@ namespace MusicPlayer
{
public partial class MainForm : Form
{
NotificationPopup p;
public Main main
{
get; set;
@@ -25,21 +26,126 @@ namespace MusicPlayer
public MainForm()
{
InitializeComponent();
PositionTrackBar.Scroll += (s, e) =>
{
if (clicked)
return;
this.PositionTrackBar_ValueChanged();
};
PositionTrackBar.MouseDown += (s, e) =>
{
clicked = true;
};
PositionTrackBar.MouseUp += (s, e) =>
{
if (!clicked)
return;
clicked = false;
this.PositionTrackBar_ValueChanged();
};
p = new NotificationPopup(this);
}
private void MainForm_Load(object sender, EventArgs e)
{
UpdateTimer.Start();
}
private void PlayButton_Click(object sender, EventArgs e)
{
AudioHandler.PlayMp3FromUrl("http://imegumii.nl/music/English/Monstercat/Direct%20-%20Eternity.mp3");
SongsTableView_CellDoubleClick(sender, new DataGridViewCellEventArgs(0, 0));
}
private void SongsTableView_SelectionChanged(object sender, EventArgs e)
private void PauseButton_Click(object sender, EventArgs e)
{
DataGridViewSelectedRowCollection col = SongsTableView.SelectedRows;
main.audio.Pause();
}
private void StopButton_Click(object sender, EventArgs e)
{
main.audio.Stop();
}
private void UpdateTimer_Tick(object sender, EventArgs e)
{
if (main.audio.BState == AudioHandler.BufferState.DONE)
PositionTrackBar.Enabled = true;
else
PositionTrackBar.Enabled = false;
BufferBar.Value = main.audio.Buffered;
PositionBar.Value = main.audio.Position;
if(!clicked)
PositionTrackBar.Value = main.audio.Position;
LabelCurrentTime.Text = main.audio.CurrentTime + "";
LabelTotalTime.Text = main.audio.TotalTime + "";
}
private void GenreListBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (GenreListBox.SelectedItems.Count != 0) {
main.GenreFilter(GenreListBox.SelectedItems[0].ToString());
}
}
private void ArtistListBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (ArtistListBox.SelectedItems.Count != 0)
main.ArtistFilter(ArtistListBox.SelectedItems[0].ToString());
}
private void AlbumListView_SelectedIndexChanged(object sender, EventArgs e)
{
if(AlbumListView.SelectedItems.Count != 0)
main.AlbumFilter(AlbumListView.SelectedItems[0].Text);
}
private void SongsTableView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
SongsTable s = new SongsTable();
if(SongsTableView.SelectedRows.Count > 0)
{
var drv = SongsTableView.SelectedRows[0].DataBoundItem as DataRowView;
var row = drv.Row as DataRow;
s.ImportRow(row);
main.audio.Play((s.Rows[0][4] as Song));
}
}
private void PositionTrackBar_ValueChanged()
{
main.audio.Seek(PositionTrackBar.Value);
}
private void notifyIcon1_Click(object sender, EventArgs e)
{
if (p.Visible)
p.Visible = false;
else
p.Visible = true;
}
private void overviewToolStripMenuItem_Click(object sender, EventArgs e)
{
this.PlaylistBox.Visible = false;
this.GenreListBox.Visible = true;
this.ArtistListBox.Visible = true;
this.AlbumListView.Visible = true;
}
private void playlistsToolStripMenuItem_Click(object sender, EventArgs e)
{
this.PlaylistBox.Visible = true;
this.GenreListBox.Visible = false;
this.ArtistListBox.Visible = false;
this.AlbumListView.Visible = false;
}
}
}
File diff suppressed because it is too large Load Diff
+1
View File
@@ -55,6 +55,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="AudioHandler.cs" />
<Compile Include="Genre.cs" />
<Compile Include="Main.cs" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
View File
+28 -14
View File
@@ -30,18 +30,21 @@
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(NotificationPopup));
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox4 = new System.Windows.Forms.PictureBox();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.BackColor = System.Drawing.Color.White;
this.groupBox1.Controls.Add(this.pictureBox4);
this.groupBox1.Controls.Add(this.pictureBox3);
this.groupBox1.Controls.Add(this.pictureBox2);
this.groupBox1.Controls.Add(this.pictureBox1);
@@ -49,11 +52,18 @@
this.groupBox1.Name = "groupBox1";
this.groupBox1.TabStop = false;
//
// pictureBox1
// pictureBox4
//
resources.ApplyResources(this.pictureBox1, "pictureBox1");
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.TabStop = false;
resources.ApplyResources(this.pictureBox4, "pictureBox4");
this.pictureBox4.Name = "pictureBox4";
this.pictureBox4.TabStop = false;
this.pictureBox4.Click += new System.EventHandler(this.pictureBox4_Click);
//
// pictureBox3
//
resources.ApplyResources(this.pictureBox3, "pictureBox3");
this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.TabStop = false;
//
// pictureBox2
//
@@ -61,11 +71,11 @@
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.TabStop = false;
//
// pictureBox3
// pictureBox1
//
resources.ApplyResources(this.pictureBox3, "pictureBox3");
this.pictureBox3.Name = "pictureBox3";
this.pictureBox3.TabStop = false;
resources.ApplyResources(this.pictureBox1, "pictureBox1");
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.TabStop = false;
//
// NotificationPopup
//
@@ -79,10 +89,13 @@
this.Name = "NotificationPopup";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Shown += new System.EventHandler(this.NotificationPopup_Shown);
this.Leave += new System.EventHandler(this.NotificationPopup_Leave);
this.groupBox1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
}
@@ -93,5 +106,6 @@
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.PictureBox pictureBox4;
}
}
+21 -1
View File
@@ -12,9 +12,29 @@ namespace MusicPlayer
{
public partial class NotificationPopup : Form
{
public NotificationPopup()
MainForm f;
public NotificationPopup(MainForm f)
{
InitializeComponent();
this.f = f;
}
private void NotificationPopup_Shown(object sender, EventArgs e)
{
System.Drawing.Rectangle workingRectangle = Screen.PrimaryScreen.WorkingArea;
this.Left = workingRectangle.Width - this.Width -10;
this.Top = workingRectangle.Height - this.Height -10;
this.Show();
}
private void pictureBox4_Click(object sender, EventArgs e)
{
f.WindowState = FormWindowState.Normal;
}
private void NotificationPopup_Leave(object sender, EventArgs e)
{
this.Visible = false;
}
}
}
+72 -35
View File
@@ -118,21 +118,60 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="pictureBox3.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<data name="pictureBox4.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQffCh0UITh4zTVoAAABr0lEQVRYR8WXQW7CMBRE
wxVY9AA9D0k4QXqCrqqqaqtKPQOVWHOgcgyWHIHCjPmmcRjiOInISE8B/+/xF9ixnaWoKJYVWINfsAcH
g5/Zxlhl6eMIhnOwAcdE2GduNmlCR/9cmdkQVnXPqJA4Aw9gB5RhH+hFz5kNo8UE8AiUyRjQWxeBAGGV
quOYcAwbtSEExvzZb7Gz4UIh0HfC/Ym2GG5iXoQGLjWVGONJtHXlf4niS/I6z/Pli/WV8Q5s3OCUCMZ4
ta5DCjh6A75eZcIN3lxHk4inUNGA728VVLzbuBeJnBTWNOAmooINyk8bM5DODWhbJVsacCdTwTpfNl4g
tLe/WqGGT5M9E7idqqDn6mdPkfCrc4gWkOflh3n1kvKs4QqI/gUo4tv8AiE2yl/QaRK2FCHza0QnYedl
qIpQeQm4ZZj0ImoWoXISOJ8fRaCVehEq3hWzcCY9NqNzESrWkWAz6rkdl8+6Pc5iUYQnZjTe80DyY8OG
QmDSIxmZ/FA63bHciwmAVd7/YuKFRP8c42rmJhyezjNZ6Nj7cnq11IYKpv56vgXN6znbEq/nWXYCplmG
3mQZHZoAAAAASUVORK5CYII=
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
EwAACxMBAJqcGAAAAcVJREFUWEftlWlOwzAQhSvBvXqBxE6AsF6Fnb9IRaq4AQK1qBywRSpv7HGapON4
+Uuf9KTW45n5so0nSlXbBD9MAipL/SjkeZ0CcM89gkqBiAJAwTuuHa1YiBiAW66ZrBiIAIBacK1sKaVX
cm3rUYCiUL9a6wuulSyl6huqIdV2Dj6CXIiY5mQBQC2GiakQnuYbPI7lYG0PwLxw1CwXwte8KPQpxYcv
Zgsw/NTKsjrHOqh3m+EZh73CVc67OYBZo9YJh426EA5AHDK4mgYxA4EreOPloLD/3eaoNR5pzcs9OQja
PDpeUeAMe175b7SQM/M1dyII/nnQQQf9Z4WGAWbJJfZ8NE1zxEtBTafTY0zOLxpivCTK9KZx6IPADL/a
HSxqQYU55BXtQd63zaExXjcc6gk9n2iPASAPIXDyXe+fauqTw17ZK+/mVBs62DhshLVnF28ByA4C1J7z
fPyWkuiK7d5+roNAj5durAdgrVe5zZ2omc3Z1aCaWP/prpEFgD0nNXeSICSHALKaOxGEcDd7DgDoJdfK
lnTbuw4+At8nGqPhCyc55h3IgkBe+6mNOQqAnAKBvWbIxDgagBwDQXukXNnV9g9jjBoLjmDoxgAAAABJ
RU5ErkJggg==
</value>
</data>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="pictureBox4.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
<data name="pictureBox4.Location" type="System.Drawing.Point, System.Drawing">
<value>227, 158</value>
</data>
<data name="pictureBox4.Size" type="System.Drawing.Size, System.Drawing">
<value>33, 32</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="pictureBox4.TabIndex" type="System.Int32, mscorlib">
<value>3</value>
</data>
<data name="&gt;&gt;pictureBox4.Name" xml:space="preserve">
<value>pictureBox4</value>
</data>
<data name="&gt;&gt;pictureBox4.Type" xml:space="preserve">
<value>System.Windows.Forms.PictureBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;pictureBox4.Parent" xml:space="preserve">
<value>groupBox1</value>
</data>
<data name="&gt;&gt;pictureBox4.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="pictureBox3.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
EwAACxMBAJqcGAAAAAd0SU1FB98KHRQhOHjNNWgAAAGvSURBVFhHxZdBbsIwFETDFVj0AD0PSThBeoKu
qqpqq0o9A5VYc6ByDJYcgcKM+aZxGOI4ichITwH/7/EX2LGdpagolhVYg1+wBweDn9nGWGXp4wiGc7AB
x0TYZ242aUJH/1yZ2RBWdc+okDgDD2AHlGEf6EXPmQ2jxQTwCJTJGNBbF4EAYZWq45hwDBu1IQTG/Nlv
sbPhQiHQd8L9ibYYbmJehAYuNZUY40m0deV/ieJL8jrP8+WL9ZXxDmzc4JQIxni1rkMKOHoDvl5lwg3e
XEeTiKdQ0YDvbxVUvNu4F4mcFNY04Caigg3KTxszkM4NaFslWxpwJ1PBOl82XiC0t79aoYZPkz0TuJ2q
oOfqZ0+R8KtziBaQ5+WHefWS8qzhCoj+BSji2/wCITbKX9BpErYUIfNrRCdh52WoilB5CbhlmPQiahah
chI4nx9FoJV6ESreFbNwJj02o3MRKtaRYDPquR2Xz7o9zmJRhCdmNN7zQPJjw4ZCYNIjGZn8UDrdsdyL
CYBV3v9i4oVE/xzjauYmHJ7OM1no2PtyerXUhgqm/nq+Bc3rOdsSr+dZdgKmWYbeZBkdmgAAAABJRU5E
rkJggg==
</value>
</data>
<data name="pictureBox3.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
<value>NoControl</value>
</data>
@@ -142,7 +181,6 @@
<data name="pictureBox3.Size" type="System.Drawing.Size, System.Drawing">
<value>33, 32</value>
</data>
<assembly alias="mscorlib" name="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="pictureBox3.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
@@ -156,20 +194,20 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;pictureBox3.ZOrder" xml:space="preserve">
<value>0</value>
<value>1</value>
</data>
<data name="pictureBox2.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQffCh0UIRU9EmkdAAABx0lEQVRYR81XS26DMBDl
EJGSdaXeoLkG0C7KtZIDZJWTdNlK6S2yzA2atu8NM9S4JnyMS5/0NMYzfjOAMXbWh6IotcX2YwUewHfw
Al6VbLOPvkrDGa+tCbDBsBvwCH6NJMdsqJHnPzcxCBhodqdiMdy7mr1gILgCz2BIcAqptSrLJ83SAQSR
dyDfa0gohtSEdkcRcNqdp0hupDZzaFZFnjfvfM7H3sVzndObmHDcmnCfgb4Y7jRt8+j5qYUCXd6Db15f
DNfNU8BF73deR0rsFpyjkKNKimgooEUNlSemloW8mn8KTYjLazDApQQ7QJ/ZmEIqCnD9DjlblGwBwGd2
SiEHDuRPJORsUbLcAGLMjinkxAH8k4WcLYr6ACDW7APYV8iFgYNWPlEdAYwxyyfyYjoer/+igFSvYMhc
kFew+CRc/DNcciF6NpGQs0UJBNA2G5NYKEIELpb7GaFBLvI7BqUGAS72jtNnug0JYRsDOP5sS1YUheRs
AAeZelP6Af7elBq4ZYYz1bacyamt2TqgRSQ5mICapQcWCDvH0UwmHKxoDoZzVuDnMvVwuq41vAk3Bu4B
AoJ2PD+B/vGcffTVyyuAtra6kGXfchVyMfY7IlMAAAAASUVORK5CYII=
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
EwAACxMBAJqcGAAAAAd0SU1FB98KHRQhFT0SaR0AAAHHSURBVFhHzVdLboMwEOUQkZJ1pd6guQbQLsq1
kgNklZN02UrpLbLMDZq27w0z1LgmfIxLn/Q0xjN+M4AxdtaHoii1xfZjBR7Ad/ACXpVss4++SsMZr60J
sMGwG/AIfo0kx2yokec/NzEIGGh2p2Ix3LuavWAguALPYEhwCqm1KssnzdIBBJF3IN9rSCiG1IR2RxFw
2p2nSG6kNnNoVkWeN+98zsfexXOd05uYcNyacJ+BvhjuNG3z6PmphQJd3oNvXl8M181TwEXvd15HSuwW
nKOQo0qKaCigRQ2VJ6aWhbyafwpNiMtrMMClBDtAn9mYQioKcP0OOVuUbAHAZ3ZKIQcO5E8k5GxRstwA
YsyOKeTEAfyThZwtivoAINbsA9hXyIWBg1Y+UR0BjDHLJ/JiOh6v/6KAVK9gyFyQV7D4JFz8M1xyIXo2
kZCzRQkE0DYbk1goQgQulvsZoUEu8jsGpQYBLvaO02e6DQlhGwM4/mxLVhSF5GwAB5l6U/oB/t6UGrhl
hjPVtpzJqa3ZOqBFJDmYgJqlBxYIO8fRTCYcrGgOhnNW4Ocy9XC6rjW8CTcG7gECgnY8P4H+8Zx99NXL
K4C2trqQZd9yFXIx9jsiUwAAAABJRU5ErkJggg==
</value>
</data>
<data name="pictureBox2.ImeMode" type="System.Windows.Forms.ImeMode, System.Windows.Forms">
@@ -194,20 +232,19 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;pictureBox2.ZOrder" xml:space="preserve">
<value>1</value>
<value>2</value>
</data>
<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQffCh0UHx1yDPpSAAABo0lEQVRYR8WXTW7CMBCF
wxVY9AA9D4ScID1BV1VVFVSpZ6ASaw5Ej8GSI1D63nRME2si/8SQJ30ieMbPI7Bju0pRXTct2IFvcAJn
hc9sY6zV9DJaLOo5TPfgkgj7zNUmTejoPr/UbAzbrmdQSJyBB3AElmEO9KLnTIexxQTwCCyTEtDbLgIB
wiqtjiXhGDqqJwRK/uxDHHW4vhDImXA/RlsMMjGv0qVmJUawerbbg/wvUXzJWecC+y+Xq08rFmAvg1NG
MBq1yCpCOuKBr1czIQYxUWUU0bIAvr+tYBQ69lWJRexYADcRK0iCs1zH7SmhiAML4E5mBQX1HBRyzDdb
ZBEnGnA7tYKC+mUJRawtzw7nmxaA/u++n4cUcJO/AO0fXZ8B5C8oPgnxdtxYuQYyCYsuQ7SFfvYusgyL
vYjw/c2PB/g7PxqBaMQAwvOrHwuhXaXzyM2oebFiAXqb0YjtuHky2mLon5jRsPUSYihzIHFCYNIjGZn8
UDrdsdyJCYBV3v9i4oRE95kzMX3Srma+0PH+l9MhwdBdzw/Av56zLfF6XlW/G66G3g3Cfq0AAAAASUVO
RK5CYII=
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAL
EwAACxMBAJqcGAAAAAd0SU1FB98KHRQfHXIM+lIAAAGjSURBVFhHxZdNbsIwEIXDFVj0AD0PhJwgPUFX
VVUVVKlnoBJrDkSPwZIjUPredEwTayL/xJAnfSJ4xs8jsGO7SlFdNy3YgW9wAmeFz2xjrNX0Mlos6jlM
9+CSCPvM1SZN6Og+v9RsDNuuZ1BInIEHcASWYQ70oudMh7HFBPAILJMS0NsuAgHCKq2OJeEYOqonBEr+
7EMcdbi+EMiZcD9GWwwyMa/SpWYlRrB6ttuD/C9RfMlZ5wL7L5erTysWYC+DU0YwGrXIKkI64oGvVzMh
BjFRZRTRsgC+v61gFDr2VYlF7FgANxErSIKzXMftKaGIAwvgTmYFBfUcFHLMN1tkEScacDu1goL6ZQlF
rC3PDuebFoD+776fhxRwk78A7R9dnwHkLyg+CfF23Fi5BjIJiy5DtIV+9i6yDIu9iPD9zY8H+Ds/GoFo
xADC86sfC6FdpfPIzah5sWIBepvRiO24eTLaYuifmNGw9RJiKHMgcUJg0iMZmfxQOt2x3IkJgFXe/2Li
hET3mTMxfdKuZr7Q8f6X0yHB0F3PD8C/nrMt8XpeVb8brobeDcJ+rQAAAABJRU5ErkJggg==
</value>
</data>
<data name="pictureBox1.Location" type="System.Drawing.Point, System.Drawing">
@@ -229,7 +266,7 @@
<value>groupBox1</value>
</data>
<data name="&gt;&gt;pictureBox1.ZOrder" xml:space="preserve">
<value>2</value>
<value>3</value>
</data>
<data name="groupBox1.Location" type="System.Drawing.Point, System.Drawing">
<value>12, 12</value>
View File
View File
View File
View File
View File
View File
Regular → Executable
+5 -1
View File
@@ -12,18 +12,22 @@ namespace MusicPlayer
public string Name { get; set; }
public string Album { get; set; }
public string Artist { get; set; }
public string Genre { get; set; }
public string Url { get { return GetURL(); } set { SetURL(value); } }
public int Seconds { get; set; }
private APIHandler api;
private string url;
public Song(string songid, string name, string album, string artist, APIHandler api)
public Song(string songid, string name, string album, string artist, string genre, int seconds, APIHandler api)
{
SongID = songid;
Name = name;
Album = album;
Artist = artist;
Seconds = seconds;
Genre = genre;
this.api = api;
+3 -1
View File
@@ -15,11 +15,13 @@ namespace MusicPlayer
this.Columns.Add("Naam", typeof(string));
this.Columns.Add("Album", typeof(string));
this.Columns.Add("Artiest", typeof(string));
this.Columns.Add("Genre", typeof(string));
this.Columns.Add("song", typeof(Song));
}
public void Add(Song s)
{
this.Rows.Add(s.Name, s.Album, s.Artist);
this.Rows.Add(s.Name, s.Album, s.Artist, s.Genre, s);
}
}
Regular → Executable
View File
View File
Regular → Executable
View File