public void AddToQueue(FileInfo fileInfo, bool startPlaying) { FlowLayoutPanel queuedSongPanel = new FlowLayoutPanel { Anchor = AnchorStyles.Left | AnchorStyles.Right, FlowDirection = FlowDirection.LeftToRight, Padding = new Padding(0), AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink }; QueuedSong queuedSong = new QueuedSong(fileInfo, queuedSongPanel); Button queuedSongSkipToButton = new Button { ImageIndex = 0, ImageList = ButtonIconList, UseVisualStyleBackColor = true, Size = new System.Drawing.Size(26, 26) }; queuedSongSkipToButton.Click += (rmsender, rmargs) => SkipToSong(queuedSong); queuedSongPanel.Controls.Add(queuedSongSkipToButton); Button queuedSongRemoveButton = new Button { ImageIndex = 2, ImageList = ButtonIconList, UseVisualStyleBackColor = true, Size = new System.Drawing.Size(26, 26) }; queuedSongRemoveButton.Click += (rmsender, rmargs) => RemoveFromQueue(queuedSong); queuedSongPanel.Controls.Add(queuedSongRemoveButton); Label queuedSongLabel = new Label { AutoSize = true, Text = fileInfo.Name, Margin = new Padding(0, 8, 2, 8), Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))) }; queuedSongPanel.Controls.Add(queuedSongLabel); if (startPlaying) { MainPlayerSkip(false); mainPlaylist.Insert(0, queuedSong); QueuePanel.Controls.Add(queuedSongPanel); QueuePanel.Controls.SetChildIndex(queuedSongPanel, 0); queuedSong.SetPlaying(true); PlayOnMainPlayer(fileInfo); } else { mainPlaylist.Add(queuedSong); QueuePanel.Controls.Add(queuedSongPanel); queuedSong.SetPlaying(false); } }
private void MainPlayerSkip(bool playNext) { if (mainPlaylist.Count == 0) { PausePlayButton.ImageIndex = 0; return; } QueuedSong currentSong = mainPlaylist.First(); MainPlayerPause(); currentSong.SetPlaying(false); mainPlaylist.Remove(currentSong); if (removeAfterTrackEnded) { QueuePanel.Controls.Remove(currentSong.panel); } else { mainPlaylist.Add(currentSong); QueuePanel.Controls.SetChildIndex(currentSong.panel, QueuePanel.Controls.Count); } if (playNext) { MainPlayerNext(); } }
private void SkipToSong(QueuedSong queuedSong) { while (mainPlaylist.First() != queuedSong) { MainPlayerSkip(false); } queuedSong.SetPlaying(true); PlayOnMainPlayer(queuedSong.fileInfo); PausePlayButton.Focus(); }
private void RemoveFromQueue(QueuedSong queuedSong) { QueuedSong currentSong = mainPlaylist.First(); mainPlaylist.Remove(queuedSong); QueuePanel.Controls.Remove(queuedSong.panel); if (queuedSong.Equals(currentSong)) { mainPlayerWMP.URL = null; MainPlayerNext(); } }
private void MainPlayerNext() { if (mainPlaylist.Count == 0) { PausePlayButton.ImageIndex = 0; return; } QueuedSong currentSong = mainPlaylist.First(); currentSong.SetPlaying(true); PlayOnMainPlayer(currentSong.fileInfo); }
private void ShuffleButton_Click(object sender, EventArgs e) { List <QueuedSong> songList = new List <QueuedSong>(mainPlaylist); while (mainPlaylist.Count != 0) { RemoveFromQueue(mainPlaylist.Last()); } Random random = new Random(); while (songList.Count != 0) { QueuedSong song = songList[random.Next(songList.Count)]; AddToQueue(song.fileInfo, false); songList.Remove(song); } }
private void MainPlayerPrev() { if (mainPlaylist.Count == 0) { PausePlayButton.ImageIndex = 0; return; } QueuedSong currentSong = mainPlaylist.First(); QueuedSong nextSong = mainPlaylist.Last(); MainPlayerPause(); currentSong.SetPlaying(false); nextSong.SetPlaying(true); mainPlaylist.Remove(nextSong); mainPlaylist.Insert(0, nextSong); QueuePanel.Controls.SetChildIndex(nextSong.panel, 0); PlayOnMainPlayer(nextSong.fileInfo); }