WriteableBitmap doesnt work on CoreSmoothStreamingMediaElement

Mar 6, 2010 at 10:27 PM
I need to create thumbnails from code. I attached mouse event to the player and tried to do the following:
            CoreSmoothStreamingMediaElement me = (sender as CoreSmoothStreamingMediaElement);
            WriteableBitmap wb = new WriteableBitmap(me.NaturalVideoWidth, me.NaturalVideoHeight);
            wb.Render(me, null);
            Image image = new Image();
            image.Height = 70;
            image.Source = wb;
This doesnt work. However if I use ExpressionPlayer and its MediaElement instead it works fine in the very same code.
Shall I report it as a bug?
Mar 15, 2010 at 8:38 PM

The reason this probably doesn't work is that CoreSmoothStreamingMediaElement derives from the SmoothStreamingMediaElement and not MediaElement.  They aren't really equivalent objects.

Mar 15, 2010 at 9:09 PM

No cchao the reason is that all the blogs I read to get the solution are actually wrong. Finally I looked into MSDN which states that you must call Invalidate after Render. All bloggers and other time wasters are simply copying same code from each other. Thank you guys!!

Once you do wb.Invalidate() everything is OK.

And btw - writeable bitmap supposed to make image of any UIElement so your guess is incorrect twice.

Mar 16, 2010 at 11:50 PM

That's good to know.  Thanks for the tip...have to add that to my memory for future use.