views:

421

answers:

1

Hi,

I have created my own video player using Flash and AS3. Within the flash movie, i have a link which allows the user to copy the object embed code and page url on their own site, similiar to youtube. The player all works fine and retrieves the right flv's depending on what page you are own. I also have the object embed code working fine. What i am having trouble with is getting the page URL.

As you can see from my code below, i am using swfobject2.2 to embed the movie on my web page and i am using FlashVars to call and play .flv within the player. I just need some JavaScript code to bring back the specific url from whatever page: flashvars.pageURL = " ";

I should also mention, i am working with jsp's within Eclipse.

<script type="text/javascript">
    var flashvars = {};
    flashvars.videoToPlay = "http://website.com/video1.flv";
    flashvars.pageURL = "This is the page url";
    var params = {};
    params.quality = "high";
    var attributes = {};

    swfobject.embedSWF("player.swf", "flashContent", "433", "328", 
        "9.0.0","expressInstall.swf", flashvars, params, attributes);
</script>

Does anyone know how i would do this? I presume it can be done using JavaScript.

thanks
Declan

A: 

According to W3C, document.URL should do the trick:

flashvars.pageURL = document.URL;
Rytmis
Hi Rytmis, by doing what you suggest..flashvars.pageURL = "document.url";This just prints out the text: document.url in the text field and does not give me the page URL. Any other ideas?
declan
Don't put it in quotes. flashvars.pageURL = document.URL;
Rytmis
That didn't work either. I got it to work in the end by using flashvars.pageURL = window.location.href works fine now.Thanks anyway
declan
I suppose that depends on the browser. I tested document.URL in Firefox and it worked. :)
Rytmis