private async void btStart_Click(object sender, EventArgs e) { if (lbSourceFiles.Items.Count < 2) { MessageBox.Show("You must add 2 or more files to test seamless playback."); return; } InitPlayer(MediaPlayer1); InitPlayer(MediaPlayer2); foreach (var item in lbSourceFiles.Items) { sourceFiles.Add(item.ToString()); } CurrentPlayer = MediaPlayer1; MediaPlayer1.Show(); MediaPlayer2.Hide(); await this.PlayFileAsync(sourceFiles[0], MediaPlayer1); sourceFiles.RemoveAt(0); await this.PlayFileAsync(sourceFiles[0], MediaPlayer2); sourceFiles.RemoveAt(0); await MediaPlayer2.PauseAsync(); }
private async void Form1_FormClosed(object sender, FormClosedEventArgs e) { if (MediaPlayer1.Status != VFMediaPlayerStatus.Free) { await MediaPlayer1.StopAsync(); } if (MediaPlayer2.Status != VFMediaPlayerStatus.Free) { await MediaPlayer2.StopAsync(); } }
private void Form1_FormClosed(object sender, FormClosedEventArgs e) { if (MediaPlayer1.Status != VFMediaPlayerStatus.Free) { MediaPlayer1.Stop(); } if (MediaPlayer2.Status != VFMediaPlayerStatus.Free) { MediaPlayer2.Stop(); } }
public void Goin() { BackExit.setBack(Goin); sNum = 0; fNum = 0; CD.setMainUI(this); time.start(); successNum.Text = "0"; failedNum.Text = "0"; status.Text = "空闲"; hasPath1 = false; hasPath2 = false; hasPath3 = false; string path1 = CD.getBasePath() + "Media\\openBox.mp4"; string path2 = CD.getBasePath() + "Media\\addCar.mp4"; string path3 = CD.getBasePath() + "Media\\closeBox.mp4"; if (File.Exists(path1)) { MediaPlayer1.Source = new Uri(path1); MediaPlayer1.Play(); hasPath1 = true; } else { MessageBox.Show("文件丢失:" + path1); } if (File.Exists(path2)) { MediaPlayer2.Source = new Uri(path2); MediaPlayer2.Play(); hasPath2 = true; } else { MessageBox.Show("文件丢失:" + path2); } if (File.Exists(path3)) { MediaPlayer3.Source = new Uri(path3); MediaPlayer3.Play(); hasPath3 = true; } else { MessageBox.Show("文件丢失:" + path3); } }
/// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } MediaPlayer1?.Dispose(); MediaPlayer1 = null; MediaPlayer2?.Dispose(); MediaPlayer2 = null; base.Dispose(disposing); }
private void WhenExit() { if (hasPath1) { MediaPlayer1.Stop(); } if (hasPath2) { MediaPlayer2.Stop(); } if (hasPath3) { MediaPlayer3.Stop(); } }
private void StopDelegateMethod2() { //timer1.Enabled = false; tbTimeline.Value = 0; MediaPlayer1.Show(); MediaPlayer2.Hide(); CurrentPlayer = MediaPlayer1; MediaPlayer1.Resume(); if (sourceFiles.Count > 0) { PlayFile(sourceFiles[0], MediaPlayer2); sourceFiles.RemoveAt(0); MediaPlayer2.Pause(); } }
private async void StopDelegateMethod1() { //timer1.Enabled = false; tbTimeline.Value = 0; MediaPlayer1.Hide(); MediaPlayer2.Show(); CurrentPlayer = MediaPlayer2; await MediaPlayer2.ResumeAsync(); if (sourceFiles.Count > 0) { await this.PlayFileAsync(sourceFiles[0], MediaPlayer1); sourceFiles.RemoveAt(0); await MediaPlayer1.PauseAsync(); } }