views:

162

answers:

2

I have seen on many sites the silverlight video player. I noticed that all of them took a URL as the source of the video file.

Can a silverlight player play a video file kept locally?

I mean a simple HTML file kept in a folder with the xap (say VideoPlayer.xap) and the video (say ABC.avi) file.

The html file would contain an object tag. For example:

<object height="240" width="500" type="application/x-silverlight-2" data="data:application/x-silverlight,">
            <param value="VideoPlayer.xap" name="source">
            <param value="onSilverlightError" name="onerror">
            <param value="white" name="background">
            <param value="cc=true,markers=true,markerpath=markers_movie21.xml,m=ABC.avi" name="initParams">
            <a style="text-decoration: none;" href="http://go.microsoft.com/fwlink/?LinkID=115261"&gt;
                <img style="border-style: none;" alt="Get Microsoft Silverlight" src="http://go.microsoft.com/fwlink/?LinkId=108181"&gt;
            </a>
        </object>
+1  A: 

There is no constraint of giving video source as URL. You can always give path of local file to be played in video.

Manoj
A: 

Yes, you can specify a URI that is within your XAP a couple of different ways. For a good resource on this, go here:

http://nerddawg.blogspot.com/2008/03/silverlight-2-demystifying-uri.html

For example, if you wanted to specify a video located in your XAP under /videos/MyVideo.avi you could specify the source like this within your XAML or code:

Source="/{assemblyShortName};/videos/MyVideo.avi"

Also, it may go without saying, but unless your project requires this for some reason, including the video within the XAP will increase the download time significantly for the .XAP file, so if at all possible, locate the video outside of the XAP file.

routeNpingme
THe video is outside the XAP. I mean it's on the local hard drive in the same folder where XAP is. Would it be possible for XAP to access that and play it?
Manish