MediaElement and local files: no luck on Silverlight

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?


~ by Luis Abreu on June 22, 2007.

2 Responses to “MediaElement and local files: no luck on Silverlight”

  1. 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. You can use MediaElement.SetSource(System.IO.Stream) to set a mediaelement”s source. Hope that helps.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: