我正在从组合框中进行选择更改。当该事件发生时,我想播放一个媒体文件,暂停5秒然后播放另一个媒体文件。实际发生的是暂停5秒。然后只播放第二个媒体文件(vb.mp4)。我在这里做错了什么?
private void cmb_adGroupZoneOne_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
this.mediaElement.Source = new Uri("C:/fb.mp4");
this.mediaElement.LoadedBehavior = MediaState.Manual;
this.mediaElement.Play();
System.Threading.Thread.Sleep(5000);
this.mediaElement.Source = new Uri("C:/vb.mp4");
this.mediaElement.LoadedBehavior = MediaState.Manual;
this.mediaElement.Play();
}
答案 0 :(得分:1)
<MediaElement Name="mediaElement" MediaEnded="mediaElement_MediaEnded" />
private void cmb_adGroupZoneOne_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
this.mediaElement.Source = new Uri("C:/fb.mp4");
this.mediaElement.LoadedBehavior = MediaState.Manual;
this.mediaElement.Play();
}
private void mediaElement_MediaEnded(object sender, RoutedEventArgs e)
{
System.Threading.Thread.Sleep(5000);
this.mediaElement.Source = new Uri("C:/vb.mp4");
this.mediaElement.LoadedBehavior = MediaState.Manual;
this.mediaElement.Play();
}