Reputation: 1054
I am making a selection change from a combobox. When that event occurs, I want to play one media file, pause 5 seconds and then play another media file. What is actually happening is that there is a 5 second pause. Then only the second media file plays (vb.mp4). What am I doing wrong here?
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();
}
Upvotes: 1
Views: 91
Reputation: 4046
<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();
}
Upvotes: 1