Jun 22

When you look at the MediaElement object, it”s obvious that it”s really easy to use when you need to play a file and you know the location of that file. When you think about it, you have several options when you want to open a movie: you can download the movie before starting to play it (using a downloader and passing it to the media element object) or you can just hook up the Source property with a specific URI. Now the problem is when you want to play a local file. Yeah, Silverlight shouldn”t let me access the user files. The problem is that you cannot get a path when you use the OpenFileDialog. You can get the name of the file or you can get the file”s contents. However, you cannot get the path to it (and I”ve even tried using reflection over it, but it failed with an exception).

Now, the problem is that the MediaElement doesn”t have any property or method that receives a stream. Now doesn”t it look like something is missing here?

2 comments so far

  1. Alex
    10:07 pm - 3-27-2008

    Well if you know a solution to play local files with silverlight please let me know. Can Silverlight open an XML file from the disk and use it?

  2. fhirzall
    3:45 pm - 11-5-2008

    You can use MediaElement.SetSource(System.IO.Stream) to set a mediaelement”s source. Hope that helps.