Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry HELP: Embedded media player URL Param and Javascript

    I have embedded media player to a page.
    The player is supposed to get the url for the file to play from a javascript that collects user choice from a form.

    The form is on one page, the javascript lies in an external .js file & the player is on another page that is called from within the javascript.

    What I cant figure out is how to pass the URL value to the media player from the javascript.
    Here's my script:

    function LocateMovie() {
    var loc = "video/";
    var add = document.form.promo.value;
    var con = document.form.speed.value;
    var url = loc + add + con + '.wmv'
    parseFloat(url);
    if (add == '') {
    alert("Please Select a sample video to view");
    } else if (con == '') {
    alert("Please select your connection speed");
    } else {
    location.href = "player.html";
    }
    }

    And voila, the notorious media player object where the 'url' variable should be inserted to fill in the value for the URL parameter:

    <Object etc..
    <param name="URL" value="??">
    * value in the above tag is equal to 'url' variable defined in the script.
    </object etc...

    Any Ideas? Other than using 12 different html pages of course...

    Regards

  • #2
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    try usign the full path name of the file, not just the short path name.

    if the page that you have i suppose in an iframe is not in the same directory as the main page, you cannot call to the file the same as if you call to it from the main page, cuz the directories are different.
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #3
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    hang on, you are using one page that opens up another window (the media player) ? and you wnat to know how to pass the url from the parent page to the media player page? is that right?
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #4
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    function LocateMovie() {
    var loc = "video/";
    var add = document.form.promo.value;
    var con = document.form.speed.value;
    var url = loc + add + con + '.wmv'
    parseFloat(url);
    if (add == '') {
    alert("Please Select a sample video to view");
    } else if (con == '') {
    alert("Please select your connection speed");
    } else {
    var ObjecT="<object><param name='URL' value='"+url+"'>"
    var MediaWin=window.open("","mywin","height=300,widht=300");
    var content="<html><head><title>Media Player</title></head>";
    content+="<body><div id=div1></div>";
    content+="</body></html>"
    MediaWin.document.getElementById('div1').innerHTML=ObjecT;

    }
    }
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.

  • #5
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

    Yes, what am trying to do is pass the url variable to the media player.
    Your solution is with no doubt a good way to go, but the thing is that my media player is within a full html page...
    So my command must target the media player object... or if there's a way to make the player object retrieve that variable by itself. For I have a parseFloat(url...) that should push the variable outside the script itself and make it accessible by other functions.
    By the way I am no javascripting genie...

    Regards

  • #6
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    By the way, I tried your solution, and got an "document.getElementById(...)' is null or not an object.

    Regards

  • #7
    Regular Coder
    Join Date
    Oct 2003
    Location
    on a ship
    Posts
    574
    Thanks
    1
    Thanked 6 Times in 5 Posts
    well im not familiar with <object> tag. I use the <embed> tag to do things such as this.

    <embed src="path/to/file/file.wmv">



    <script type=text/javascript>
    var MediaWin
    function ChngEmb(url){
    MediaWin=window.open('','mywin',"width=400,height=400,toolbars=no,status=no");
    if(MediaWin.document.getElementById('div1')){
    MediaWin.document.getElementById('div1').innerHTML="<embed src='"+url+"' id=embedObj>";
    MediaWin.focus();
    }else{
    var contents="<html><head><title>Media Player</title></head><body>";
    contents+="<div id=div1><embed src='"+url+"' id=embedObj></div></body></html>"
    MediaWin.document.write(contents);
    }
    }
    </script>


    <input type=button value='play 1' onclick="ChngEmb('path/to/file/file.wmv');">
    <input type=button value='play 2' onclick="ChngEmb('path/to/file/file2.wmv');">
    I make no attempt at pretending like I'm a professional. I offer help with what knowledge I do have.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •