Pass QueryString Value to Silverlight javascript file

Hi
I just downloaded the trial version of Expression encoder and built a silverlight video player,
Question is how can i change which video to play based on a querystring value.

In the javascript code snippet below, i want to change: mediaUrl": "WinVideo-HDI-VS08-AJAX-Support.wmv  to a variable called: vidToPlay which would have the name of the video to play attached to a querystring ?vidToPlay=WinVideo-HDI-VS08-AJAX-Support.wmv.

Any help would be appreciated
George

--------------------------------------------------

function get_mediainfo(mediainfoIndex) {
    switch (mediainfoIndex) {        

        case 0:
            return  { "mediaUrl": "WinVideo-HDI-VS08-AJAX-Support.wmv",
                      "placeholderImage": "",
                      "chapters": [              
                                  ] };                                                                
                         
        default:
             throw Error.invalidOperation("No such mediainfo");
     }
}
ImInNeedOfHelpAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

b0lsc0ttIT ManagerCommented:
If I understand you correctly you want ...

var vid2play = document.location.href.toString().match(/?vidToPlay=(.+)$/)[1];

... and then ...

function get_mediainfo(mediainfoIndex) {
    switch (mediainfoIndex) {        

        case 0:
            return  { "mediaUrl": vid2play,
                      "placeholderImage": "",
                      "chapters": [              
                                  ] };                                                                
                         
        default:
             throw Error.invalidOperation("No such mediainfo");
     }
}

This assumes that is all you have in the URL.  Also I assume you just want to change the file name and the "mediaUrl" part is important as it is.

Let me know how this works or if you have a question.

bol
0
ZvonkoSystems architectCommented:
Check this:
var vidToPlay="WinVideo-HDI-VS08-AJAX-Support.wmv";
if(location.search){
  var _par = location.search.split(/vidToPlay\=/i);
  if(_par.length>1){
    vidToPlay=unescape((_par[1]+"&").split("&")[0]);
  }
}
 
function get_mediainfo(mediainfoIndex) {
    switch (mediainfoIndex) {        
 
        case 0:
            return  { "mediaUrl": vidToPlay,
                      "placeholderImage": "",
                      "chapters": [               
                                  ] };                                                                
                          
        default:
             throw Error.invalidOperation("No such mediainfo");
     }
} 

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ImInNeedOfHelpAuthor Commented:
Hi
Sorry for delay, never got email from EE saying reply had been posted.

Below is what i currently have:

-------------------------------------Index.aspx page
public string vidToPlay;
protected void Page_Load(object sender, EventArgs e)
        {
        vidToPlay = Request.QueryString["VidID"].ToString();
       }

----------------------- JS Class------------------------------

function get_mediainfo(mediainfoIndex) {
    switch (mediainfoIndex) {        

        case 0:
            return  { "mediaUrl": "WinVideo-HDI-VS08-AJAX-Support.wmv",
                      "placeholderImage": "",
                      "chapters": [              
                                  ] };                                                                
                         
        default:
             throw Error.invalidOperation("No such mediainfo");
     }
}

------------------------
So I need to pass: WinVideo-HDI-VS08-AJAX-Support.wmv which would be the value vidToPlay to the JS class and insert the value here:   return  { "mediaUrl": "WinVideo-HDI-VS08-AJAX-Support.wmv",

Hope this explains things more clearly
George
0
ImInNeedOfHelpAuthor Commented:
I'm a novice at javascript, but once i relized i could put the var VidToPlay in my aspx page then create a variable that i could insert into code i then understood how it works.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.