Make sure you set the Project Properties as above enabling the out-of-browser and ensuring "Require elevated trust.Create a new Silverlight 5 Project (VB.NET) and give it any name you wish.This sample was tested using Silverlight 5 RC? Step 1 Set our custom class as the source stream to the MediaElement control in UI, behind-code.Write our custom class that is derived from and override all the required methods.Prepare a simple UI with a MediaElement control, two buttons, and a checkbox.We shall use the following simple steps to achieve our goal: avi) to play, you must have the relevant codec on your machine first. Our main objective in this article is to write a simple Silverlight application that plays back an AVI video. To report back to MediaElement that the sample is ready, we call the ReportGetSampleCompleted() method. MediaElement will call this method every time it needs a sample. GetSampleAsync: We override this method and retrieve the next requested sample by the MediaElement.OpenMediaAsync: We override this method, and in it, we initialize and report some metadata about the media by calling the ReportOpenMediaCompleted() method.
#Silverlight download file stream code#
I will not dig deep into defining these methods, but the ones we shall use in our example code are: Without going into too much detail, the methods are OpenMediaAsync, GetSampleAsync, CloseMedia, SeekAsync, GetDiagnosticsAsync, and SwitchMediaStreamAsync. This will require us to override a number of methods. To recap from the previous article, we need to first derive our custom class from.
Silverlight 5 comes with the Platform Invoke support for calling native code (among many other great features). MediaElement (MediaStreamSource) as well as WriteableBitmap Implementation BackgroundĪs of 1 st of September 2011, Silverlight 5 RC has been made available for download (see Pete's blog - link above). Please Note the second download ( CMS_S5_plusWriteableBitmap) includes displaying the same Video Samples using the WriteableBitmap. So in short, just as the previous article, this HowTo article tries to demonstrate the power of the MediaElement and MediaStreamSource classes with P/Invoke support to call native code to play an AVI video. It is important to go through that article first - most of the steps covered there won't be covered here. Our objectives for this HowTo article is no different from my previous article with almost exactly the same Title. Silverlight 4 did not have P/Invoke support for calling native functions Silverlight 5 does (see Pete Brown's blog for more details).
#Silverlight download file stream plus#
Download CMSS_S5_plusWriteableBitmap - 86.79 KB ( MediaElement plus WriteableBitmap).Download source - 78.15 KB ( MediaElement Only).