www.webdeveloper.com
Results 1 to 3 of 3

Thread: jwplayer donít work when using Ajax script

Hybrid View

  1. #1
    Join Date
    Oct 2013
    Posts
    26

    jwplayer donít work when using Ajax script

    jwplayer donít work when using Ajax script

    Hope someone can help me.

    Iím building up a small and simple CMS. In the CMS there is a movie and a photo page where a thumb of the photo or movie is loaded in the right side of the page and in the left side the photo or movie is showed.

    The left side where the movie or photo is showed is loaded using an Ajax script. The Issue is that the movies donít show up. Iím using jwplayer to show movies. Itís loaded dynamic by an auto generated link:

    HTML Code:
    <a href=\"javascript:ajaxpage('movie-view.php?var1=" .$mov1. "&var2=" . $displayMovieLowPath ."', 'rightcolumn');\">Watch movie 1</a>

    The Ajax code looks like this (I have not written this myself!):

    PHP Code:
    <script type="text/javascript">
    /***********************************************
    * http://dynamicdrive.com/dynamicindex17/ajaxcontent.htm
    ***********************************************/
    var loadedobjects=""
    var rootdomain="http://"+window.location.hostname
    function ajaxpage(urlcontainerid){
    var 
    page_request false
    if (window.XMLHttpRequest// if Mozilla, Safari etc
    page_request = new XMLHttpRequest()
    else if (
    window.ActiveXObject){ // if IE
    try {
    page_request = new ActiveXObject("Msxml2.XMLHTTP")

    catch (
    e){
    try{
    page_request = new ActiveXObject("Microsoft.XMLHTTP")
    }
    catch (
    e){}
    }
    }
    else
    return 
    false
    page_request
    .onreadystatechange=function(){
    loadpage(page_requestcontainerid)
    }
    page_request.open('GET'urltrue)
    page_request.send(null)
    }
    function 
    loadpage(page_requestcontainerid){ 
    if (
    page_request.readyState == && (page_request.status==200 || window.location.href.indexOf("http")==-1)) 
    document.getElementById(containerid).innerHTML=page_request.responseText

    function 
    loadobjs(){
    if (!
    document.getElementById)
    return
    for (
    i=0i<arguments.lengthi++){
    var 
    file=arguments[i]
    var 
    fileref=""
    if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
    if (file.indexOf(".js")!=-1){ //If object is a js file
    fileref=document.createElement('script')
    fileref.setAttribute("type","text/javascript");
    fileref.setAttribute("src"file);
    }
    else if (
    file.indexOf(".css")!=-1){ //If object is a css file
    fileref=document.createElement("link")
    fileref.setAttribute("rel""stylesheet");
    fileref.setAttribute("type""text/css");
    fileref.setAttribute("href"file);
    }
    }
    if (
    fileref!=""){
    document.getElementsByTagName("head").item(0).appendChild(fileref)
    loadedobjects+=file+" " //Remember this object as being already added to page
    }
    }
    }
    </script> 
    I think somehow the script donít send all info to the movie-view.php page that is loads using the Ajax.


    If I donít load the page using the Ajax script like this:
    HTML Code:
    <a href=\"movie-view.php?var1=" .$mov1. "&var2=" . $displayMovieLowPath ."\" target=new>Watch movie 1</a>
    The page open and load and the jwplayer works just fine.


    I think there needs to be add some codes to the Ajax script around this spot:

    PHP Code:
    function loadpage(page_requestcontainerid){ 
    if (
    page_request.readyState == && (page_request.status==200 || window.location.href.indexOf("http")==-1)) 
    document.getElementById(containerid).innerHTML=page_request.responseText

    But I have no idea of what to add or how the codes should look like.


    If itís a help/hint I had the same issue with photos where I use Shadowbox.js (http://www.shadowbox-js.com/) to show my photos. The Shadowbox did not show up when clicking a thumb on the page loaded using the Ajax script, then I add the this piece of code to the script: Shadowbox.setup(); so it ended look like this:
    PHP Code:
    function loadpage(page_requestcontainerid){ 
    if (
    page_request.readyState == && (page_request.status==200 || window.location.href.indexOf("http")==-1)) 
    document.getElementById(containerid).innerHTML=page_request.responseText
    Shadowbox.setup(); 


    Hope someone can help me getting the jwplayer work.

    THANKS

  2. #2
    Join Date
    Oct 2013
    Posts
    26
    Here comes a Little bonus info. It is the latest version 6.7 im using.

    The codes for calling the movie looks like:

    div id="myElement">Loading the player 6...</div>
    <script type="text/javascript">
    jwplayer("myElement").setup({
    file: "<? echo($_GET["var2"].$f4vfilenameext) ?>",
    height: 360,
    image: "/uploads/example.jpg",
    width: 640
    });
    </script>

  3. #3
    Join Date
    Oct 2013
    Posts
    26
    Please advice on this - im stuck

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles