Answer the question
In order to leave comments, you need to log in
How to update video frame in MediaElement? C# WPF?
Solution found. In XAML, you need to add a property to the element tag ScrubbingEnabled="True"
.
There is a media element, it contains an AVI video. By clicking on one button, the method is executed mediaElement.Play();
, on the other - mediaElement.Pause();
There is a slider, the value of which is used to set the position of the video.
public DispatcherTimer _timer = new DispatcherTimer();
public int waitnum = 3000;
double TotalTime = 0;
public MainWindow()
{
_timer.Interval = TimeSpan.FromSeconds(1);
_timer.Tick += new EventHandler(_timer_Tick);
InitializeComponent();
}
void _timer_Tick(object sender, EventArgs e)
{
double tPass = mediaElement1.Position.TotalSeconds;
slider.Value = tPass;
}
private void mediaElement1_MediaOpened(object sender, RoutedEventArgs e)
{
slider.Maximum = mediaElement1.NaturalDuration.TimeSpan.TotalSeconds;
}
private void slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
_timer.Stop();
TimeSpan ts = TimeSpan.FromSeconds(slider.Value);
mediaElement1.Position = ts;
textBox.Text = ts + " / " + mediaElement1.NaturalDuration;
_timer.Start();
}
. . .
mediaElement.Pause();
) and then move the slider, the position of the video changes, but the frame is not updated. How can I refresh a frame on pause?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question