Skip to main content

Microsoft Silverlight

Answered Question How to use InitParameters="m=" with files not in ClientBin folder?RSS Feed

(0)

Viktor_kulik
Viktor_k...

Member

Member

3 points

14 Posts

How to use InitParameters="m=" with files not in ClientBin folder?

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
preishuber

Contributor

Contributor

3570 points

655 Posts

Answered Question

Re: How to use InitParameters="m=" with files not in ClientBin folder?

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

-Hannes

http://www.preishuber.net http://weblogs.asp.net/hpreishuber

fullsailrick
fullsail...

Contributor

Contributor

3699 points

829 Posts

Re: How to use InitParameters="m=" with files not in ClientBin folder?

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.

fullsailrick
fullsail...

Contributor

Contributor

3699 points

829 Posts

Re: How to use InitParameters="m=" with files not in ClientBin folder?

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.)

Viktor_kulik
Viktor_k...

Member

Member

3 points

14 Posts

Re: How to use InitParameters="m=" with files not in ClientBin folder?

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

fullsailrick
fullsail...

Contributor

Contributor

3699 points

829 Posts

Re: How to use InitParameters="m=" with files not in ClientBin folder?

#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

Viktor_kulik
Viktor_k...

Member

Member

3 points

14 Posts

Re: Re: How to use InitParameters="m=" with files not in ClientBin folder?

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.

Viktor_kulik
Viktor_k...

Member

Member

3 points

14 Posts

Re: How to use InitParameters="m=" with files not in ClientBin folder?

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.

fullsailrick
fullsail...

Contributor

Contributor

3699 points

829 Posts

Re: How to use InitParameters="m=" with files not in ClientBin folder?

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.

Viktor_kulik
Viktor_k...

Member

Member

3 points

14 Posts

Re: How to use InitParameters="m=" with files not in ClientBin folder?

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.

Viktor_kulik
Viktor_k...

Member

Member

3 points

14 Posts

Re: How to use InitParameters="m=" with files not in ClientBin folder?

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.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities