Skip to main content
Home Forums General Silverlight Getting Started How to use InitParameters="m=" with files not in ClientBin folder?
10 replies. Latest Post by Viktor_kulik on January 8, 2009.
(0)
Viktor_k...
Member
3 points
14 Posts
01-07-2009 3:39 AM |
This is regarding the SL2 video player. Possibly a very beginner question but I have tried every way I know and the only way I can play any files is if they are somewhere inside of the clientbin where the videoplayer.xap is located. They can be inside of another folder there but I have my media in a different folder all together, right at the root (root\media). So how would I go about pointing it in a different location? This is the asp.net code I have and the commented out part is my attempt to get the filename from the url query. It only works if its inside of the folder: '--%> Thanks, Viktor
preishuber
Contributor
3570 points
655 Posts
01-07-2009 9:20 AM |
with relative path it is not possible to go one step higher as clientbin
absolute path like http://www.blabla.com/movie.wmv should work
fullsail...
3699 points
829 Posts
01-07-2009 10:55 AM |
I'm like you, I almost always get the stupid path wrong. I don't know if this helps -- but what I do is create a string just before I set the videoPlayer's Source -- to see where it is referencing and I cross-reference that with where the file actually is.
01-07-2009 10:58 AM |
Oh, but hey, you do realize that Silverlight can't access the local hard drive, right? (for security reasons that aren't apparent until you pretend that you have one of those evil mustaches and top hats -- and a monocle, you have to have one of those too.)
01-07-2009 12:32 PM |
Thanks for the answer, tested and it does work as you say it does, I did test this before but since i'm on a local drive right now, i tested it with application path and that did not work, if i set it to localhost, then it does so that gives me hope that it will work on the web. 2 questions though: 1. Is there a variable that will return the root web address? 2. I'm having a problem getting this to work, i'm retrieving the file name from the url: '' This website has C# for code behind, not my preference, so am i doing anything wrong here? it looks pretty straight forward. Should i have in the header info? I didn't think it was necessary in this case. Thanks, Viktor
01-07-2009 12:52 PM |
#1. I'm trying to better understand your situation, so tell me why you need the root web address? #2. I can't see what you pasted. :O
01-07-2009 12:58 PM |
oh, sorry i guess it got cut out, here's my situation: One page has a hyperlink to my player page, so from that first page I add a stringquery to the url that contains the media file name. On the player page, i need to create the absolute path to the media file, so to do that I need the "http://localhost:2136/media/" & retrieve the filename from the string query. So to do that I do: InitParameters=(left arrow & percent)"m=http://localhost:2136/media/" + Page.Request.QueryString["item"](percent & right arrow) but that does not seem to work.
01-07-2009 1:24 PM |
I guess the question i should ask is how do you set a code-behind variable (c#) to "m=" property? I have a filename variable that should work, that filename variable is a string "m=http://localhost:2136/media/test.wmv" if i copy and paste that string into the initparementer, it works, but if i use the filename it does not work. Of course I get the filename with the arrow percent thingy that keeps on getting cut out of my posts.
01-07-2009 1:57 PM |
Does this screencast answer your question? http://mschnlnine.vo.llnwd.net/d1/ch9/2/9/4/5/1/4/MT_B2_InitParams.wmv You're on the right track. Pass in the name of the video to play and build the URI in the silverlight app, then set the mediaplayer source to that uri.
01-07-2009 6:11 PM |
The thing is, I did not build this video player, i'm using the default videoplayer.xap from codeplex. So I don't have a place to do this in xaml, only asp.net and code behind.
01-08-2009 10:06 AM |
if anyone stumbles over this thread, i ended up passing the media source name in code behind on page load, don't know why i didn't think of that right off the top.