I implemented a simple video player. In it, there is a MediaElement and a Slider, among other things. Anyway, when I slide the slider all the way to the right and set the MediaElement.Position to the very end of the video, the video FREEZES on the last frame of the video and will not resume or respond to pause/play commands until I load a different video into the MediaElement.
I put in a small hack to only change the Position value to numbers that are at least 20 milliseconds from the end of the video, and the problem went away:
if ( _mediaElement.HasVideo &&
_mediaElement.NaturalDuration.HasTimeSpan &&
(_mediaElement.NaturalDuration.TimeSpan.TotalMilliseconds - e.NewValue) > 20)
{
_mediaElement.Position = new TimeSpan(0, 0, 0, 0, (int) e.NewValue);
}
What I don't understand is why does the video freeze on the last frame? Is this a bug in the MediaElement control, or is there some other way to work around this problem?
I found a post from 3 years ago describing what seems like the same problem, and their solution was an updated nVidia driver. I have the most up to date nVidia driver and still have this problem. I guess the above hack works, but it seems kinda strange that the video would just lock up like that.