Tuesday, June 23, 2009

WPF crashes on XP when using MediaElement

The MediaElement has been the bane of my life for some time now. In our first release, we actually used the Windows Media Player in a dll, because we had issues with performance. I did ask about this many times on MSDN forums and never got a real answer. A lot of other people were asking, too, so let me answer that question: even when you're playing a video in a form that has no real 3D, you're still creating a video on a DirectX surface, because that's how WPF works. So, it's not surprising really when a MediaElement is not as smooth as Windows Media Player, which just throws frames at the screen. The resolution of a DVD is around 800 x 600, (although HD is bigger, so is your LCD TV bigger than the average monitor), if your video is much bigger, remember that doubling the width of your video ( so if you go 1600 x 1200 ), gives you four times as many pixels that need to be scaled and drawn. It took me a while to work this out, but once I got our videos rendered in a sensible resolution, they play just fine in the media element ( I did a project where playing one video was unreliable, because of high resolution, I didn't generate the videos, and when I checked the resolution, it all made sense ).

I use a Mac ( I need to post about Boot Camp, actually ). As a result, I probably rebuild my Windows more often than most, as it's easy to build a new VM without even touching the old one. As a result, I have more experience than most with the fact that if you install Windows XP, SP2, and then install .NET 3.5 and run a WPF app that has a media element in it, one of several things will happen:

1 - The app will blow up on start, with a message that the XAML is invalid
2 - If you try to show still images on the MediaElement, it just won't do anything at all.

It seems to me that if I install a framework, it should work from there. It also seems to me like if I need to install a specific extra component, that I could get a meaningful error message to tell me what is going on. The first time this happened to me, I spent a half day trying to work out why my code was broken. I don't believe that winforms ever had this sort of issue. I presume there's a reason why WPF requires WMP10, but if that's true, why can't it try to tell me ? I can see how Microsoft has had legal trouble for bundling stuff in the past, but I am either going to install WMP10, or I am going to not use the application I just bought ( assuming now I am an end user ). How does making it confusing, help anyone ? What if the install for WMP10 fails somehow ( remembering my post the other day on installers ) ? This is just going to cause work and headache for support staff, and general frustration for end users.

Of course, it works fine out of the box in Vista. The only downside is, then you're using Vista.

No comments:

Post a Comment