Web Analytics Made Easy -
StatCounter Using Javascript to call video in XML playlist - CodingForum

Announcement

Collapse
No announcement yet.

Using Javascript to call video in XML playlist

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Javascript to call video in XML playlist

    Hey all,

    This is my first post

    I'm using the JW Flash video player on my site. I've used some javascript in the head which means the user can type in the specific address to call a specific video from a specific XML play list (i.e video_player.php?=playlist1&item=1.) This works pretty well, but sometimes decides to play only the audio and display the image at the very top of my playlist.

    Is there something wrong with my Javascript and is this the best way to call a specific element using Javascipt?

    Here's the <head>

    Code:
    <!-- Flash detect -->
    <script type="text/javascript" src="js/flash/flash_detect.js"></script>
    
    <!-- Video URL JUMP -->
    <script language="JavaScript" type="text/javascript">
    var player = null;
    var playItem = null;
    var file = null;
    
    
    if(!(playItem = getQueryParamValue('item')))
    {
    //...default is first item (array counting starts at 0)
    playItem = 0;
    }
    
    if(!(file = getQueryParamValue('playlist')))
    {
    //...default playlist
    file = 'video/xml/playlist1.xml';
    }
    
    function playerReady(obj)
    {
    player = gid(obj.id);
    playAway();
    };
    
    
    //...start the player on the query parameter item
    function playAway()
    {
    if(player.getPlaylist())
    {
    player.sendEvent('ITEM', playItem);
    player.sendEvent('PLAY', 'true');
    gid('playaway').innerHTML = 'playAway: Player: ' + player.id + ' playItem: ' + playItem + ' File: ' + file;
    }
    else
    {
    setTimeout("playAway()", 100);
    }
    };
    
    
    function gid(name)
    {
    return document.getElementById(name);
    };
    </script>
    Here's the <body>

    Code:
    <div id="body">
    
    <h2>Whoops!</h2>
    <p>It looks like you don't have Flash!</p>
    
    <script type="text/javascript">
    var so = new SWFObject('video/swf/player.swf','mpl','914','600','9', '000000');
    so.addParam('allowscriptaccess','always');
    so.addParam('allowfullscreen','false');
    so.addParam('menu','false');
    so.addParam('flashvars','&author=Me&file=video/xml/playlist1.xml&backcolor=000000&frontcolor=FFFFFF&lightcolor=C9DD77&playlistsize=314&skin=video/swf/skin.swf&playlist=right&stretching=none&autostart=true&bufferlength=20');
    so.write('body');
    </script>
    </div>
    Please note, I'm using PHP echo in the body of the code to switch between playlists (I have 3). However: there is no echo in the head where it says "//...default playlist".

    Thanks
Working...
X