views:

75

answers:

3

I am using Silverlight Media Framework in one of my project. Now i want to play a media file in the browser, the media file is in my D drive of PC? I code in XAML to play the file but the SMF player is not getting the media source. The code of XAML that am using to access the file is following.

<Core:SMFPlayer>
        <Core:SMFPlayer.Playlist>
            <Media:PlaylistItem MediaSource="file:///D:/Microsoft Silverlight/1.wmv"></Media:PlaylistItem>
        </Core:SMFPlayer.Playlist>
    </Core:SMFPlayer>
+2  A: 

Silverlight runs in a secure sandbox and you can't simply access the local filsystem. You will have to use an OpenFileDialog to let the user select a file. Then you can set the source of the MediaPlayer. Keep in mind that the OpenFileDialog has to be called from an user-initiated event, like a Button.Click.

Alternatively you can put the file on the web server and load it from there. You can also use relative paths. Just put it into the ClientBin folder of your Web project.

Rene Schulte
A: 

An alternative method is to host the file on your local IIS server. One problem I ran into when doing this was that the default IIS installation does not give your application the correct permissions when using "Pass Through Authentication". Therefore, make sure that the "Pass Through Account" has read access to the path where your video file is located. Usually, the "Pass Through Account" is the same account that your application's app pool is using. For normal installations this will be the Network Service built-in account.

l3a0
A: 

You need to put the media file in the Silverlight application. Then, go to the properties of the media file and change the build action to resource. Reference the file by local name (just myfile.myextension, not C:/[mypath]/[myfilename]) in the mediasource property of the playlistitem element.

vbullinger