private void Play_Click(object sender, EventArgs e) { CircularButton btn = (CircularButton)sender; if (FilePath == null || FilePath.Count == 0) { return; } if (playing == false) { mediaPlayer.Play(); playing = true; btn.BackgroundImage = UI_Media.Properties.Resources.pause; System.Windows.Forms.Integration.ElementHost spectrum = (System.Windows.Forms.Integration.ElementHost)playingUC2.Controls.Find("elementHost1", true)[0]; spectrum.Visible = true; } else if (playing == true) { mediaPlayer.Pause(); playing = false; btn.BackgroundImage = UI_Media.Properties.Resources.play_button; System.Windows.Forms.Integration.ElementHost spectrum = (System.Windows.Forms.Integration.ElementHost)playingUC2.Controls.Find("elementHost1", true)[0]; spectrum.Visible = false; } }
private void MediaPlayer_MediaEnded(object sender, EventArgs e) { if (repeat_mode == 0) { if (i == FilePath.Count - 1) { playing = false; mediaPlayer.Stop(); CircularButton btn = (CircularButton)playingUC2.Controls.Find("play", true)[0]; btn.BackgroundImage = UI_Media.Properties.Resources.play_button; } else { i++; mediaPlayer.Open(new Uri(FilePath[i], UriKind.Absolute)); mediaPlayer.Play(); } } else if (repeat_mode == 1) { mediaPlayer.Position = new TimeSpan(0); } else { i = (++i) % FilePath.Count; mediaPlayer.Open(new Uri(FilePath[i], UriKind.Absolute)); mediaPlayer.Play(); string FileName = System.IO.Path.GetFileName(FilePath[i]); this.Text = label1.Text = FileName + " - Media Player"; System.Windows.Forms.Label lb = (System.Windows.Forms.Label) this.playingUC2.Controls.Find("label3", true)[0]; lb.Text = FileName; } }
private void MediaPlayer_MediaOpened(object sender, EventArgs e) { changeTitle(i); playingUC2.duration = GetVideoDuration(FilePath[i]); //Chơi CircularButton btn = (CircularButton)playingUC2.Controls.Find("play", true)[0]; mediaPlayer.Play(); playing = true; btn.BackgroundImage = UI_Media.Properties.Resources.pause; //Hiện spectrum System.Windows.Forms.Integration.ElementHost spectrum = (System.Windows.Forms.Integration.ElementHost)playingUC2.Controls.Find("elementHost1", true)[0]; spectrum.Visible = true; //Hiện time tổng cộng Label lb2 = (Label)playingUC2.Controls.Find("label2", true)[0]; lb2.Text = playingUC2.duration.ToString(@"hh\:mm\:ss"); lb2.Visible = true; Label lb1 = (Label)playingUC2.Controls.Find("label1", true)[0]; lb1.Visible = true; //Label lb3 = (Label)playingUC2.Controls.Find("label3", true)[0]; //lb3.Visible = true; //Cho phép dùng Seek bar TrackBar track = (TrackBar)playingUC2.Controls.Find("seek", true)[0]; track.Enabled = true; }
public PlayMainForm() { InitializeComponent(); CircularButton play = (CircularButton)playingUC2.Controls.Find("play", true)[0]; play.Click += Play_Click; TrackBar seek = (TrackBar)playingUC2.Controls.Find("seek", true)[0]; seek.ValueChanged += Seek_ValueChanged; playlistUC1.AutoScroll = true; }