Reputation: 137
I am using a MediaElement for viewing both normal images and gif images, but the gifs freeze after 5 seconds every time. The ones that are longer than 5 seconds dont finish, while those who are less than 5 seconds get looped until it reaches that magical number.
Ive tried doing manual unload on the image, force playing it - nothing works.
private void NewUri(string path)
{
MediaView.Source = new Uri(path, UriKind.Absolute);
if (Path.GetExtension(path) == ".gif")
{
isAnimated = true;
}
else
isAnimated = false;
OnImageChanged();
GC.Collect();
}
private void OnImageChanged()
{
isPaused = false;
MediaView.Play();
border.Reset();
}
private void OnClipEnded(object sender, RoutedEventArgs e)
{
MediaView.Position = TimeSpan.Zero;
MediaView.Play();
}
Upvotes: 0
Views: 199
Reputation: 137
Upon more brute force testing I found out that writing new TimeSpan(0, 0, 1);
instead of TimeSpan.Zero;
fixes the issue, somehow.
I would still like to know why that is if anyone knows. But if it works, it works
Upvotes: 1