I want to smoothly play video in backwards direction in WPF. I am using MediaElement
to play the video. I read this post which suggests changing MediaElement.Position
periodically to mimic the rewinding behaviour.
I tried following code for changing position of MediaElement.Position
private void Button_Click(object sender, RoutedEventArgs e)
{
mePlayer.Pause(); //Pause the media player first
double m = 1 / frameRate; //Calculate the time for each frame
double t = 120; //Total length of video in seconds
mePlayer.Position = TimeSpan.FromMinutes(2); //Start video from 2 min
while (t >= 60) //Check if time exceeds 1 min
{
t = t - m; //Subtract the single frame time from total seconds
mePlayer.Position = TimeSpan.FromSeconds(t);//set position of video
}
}
In above code I am trying to play video backwards from 2 min to 1 min.
It's giving me 'System.OverflowException' on mePlayer.Position = TimeSpan.FromSeconds(t)
.
If anyone know how play video backwards in WPF, please help me to achieve this effect. Thank you.