Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

cant get thisto work

5 replies [Last post]

Ive been trying for hours to get this to work, its a hover autostart script. If i link to the video directly it works but if i use a xml playlist it wont

<html>

<head>
<title>Multiple Player Mouseover Example</title>

<style type=text/css>

#placeholder1 { position:absolute; left:32px; top:100px; z-index:1 }
#placeholder2 { position:absolute; left:32px; top:250px; z-index:1 }

#place1 { position:absolute; left:32px; top:100px; width:160; height:130; z-index:2 }
#place2 { position:absolute; left:32px; top:250px; width:160; height:130; z-index:2 }
</style>

<script type="text/javascript" src="/swfobject.js"></script>

<script type="text/javascript">
var currentPlayer=null;
var currentFile;
var currentImage;

function removeOldPlayer() {
document.getElementById(currentPlayer).innerHTML = '<img src="'+currentImage+'" border="0" onclick="createPlayer(\''+currentPlayer+'\', \''+currentFile+'\', \''+currentImage+'\')">';
}

function createPlayer(thePlace, theFile, theImage, go) {
if (currentPlayer!=null) { removeOldPlayer(); }

currentPlayer=thePlace;
currentFile=theFile;
currentImage=theImage;

var s = new SWFObject("/player.swf","playerID","140","110","7");
s.addParam('allowscriptaccess', 'always');
s.addParam('flashvars','file='+theFile+''&controlbar=none&autostart=true&overstretch=fit&showicons=false');
s.write(thePlace);
}
</script>

</head>

<div id="placeholder1"><a href="http://www.macromedia.com/go/getflashplayer"><img src="/thumb/1573.jpg" width="140" height="110" border="0"></a></div>
<div id="placeholder2"><a href="http://www.macromedia.com/go/getflashplayer"><img src="/thumb/1974.jpg" width="140" height="110"border="0"></a></div>

<div id="place1"><img src="/thumb/1_1573.jpg" width="140" height="110" onmouseover="createPlayer('placeholder1', '/play.php?id=389', '', true)" onmouseout="removeOldPlayer()"></div>
<div id="place2"><img src="/thumb/1974.jpg" width="140" height="110" onmouseover="createPlayer('placeholder2', '/12325942212097480389.flv', '', true)" onmouseout="removeOldPlayer()"></div>

</body>
</html>

and in play.php

<?php

echo '<?xml version="1.0" encoding="UTF-8"?><playlist xmlns="http://xspf.org/ns/0/" version="1"><title>mixmedia</title> <tracklist>';
echo"<track>
<location>12325942212097480389.flv</location>
<image>/thumb/img.jpg</image>
</track>";

?>

You are missing the closing tags for the playlist:

<?php

echo "<?xml version='1.0' encoding='UTF-8'?>
<playlist xmlns='http://xspf.org/ns/0/' version='1'>
  <title>mixmedia</title>
  <trackList>";

echo "    <track>
      <location>12325942212097480389.flv</location>
      <image>/thumb/img.jpg</image>
    </track>";

echo "  </trackList>
</playlist>";

?>

Sorry must have deleted it outta this post.

Yes i do have the closing tags.

Im using play.php to play single videos but this script wont work with xml playlist.

Any ideas??

i had a look at my error log , its trying to access:

crossdomain.xml

Why is this?

This is an Adobe flash Player security restriction. When you try to load a data file from a domain that is different from the domain that the movie was loaded from, Flash will look for a cross-domain policy file on the domain that the data file is being loaded from.

That does not appear to be the case because you are loading:

http://domain/player.swf
http://domain/play.php?id=389

The request for the cross-domain policy file could also be caused your failure to urlencode the file URI.

Try using:

s.addParam('flashvars','file=' + encodeURIComponent(theFile) + '&controlbar=none&autostart=true&overstretch=fit&showicons=false');

Note that you had two single quotes before &controlbar, which is a mistake.

Also, the showicons and overstretch flashvars are not v4 player supported flashvars. You probably want to use icons and stretching.

See: http://developer.longtailvideo.com/trac/wiki/FlashVars

Thanks for the help.

I got it working, i just moved the swf and player to a directory

http://site.com/player/swfobject.swf
http://site.com/player/player.swf

Im not sure why this was, maybe something to do with my htaccess file,

Anyways thanks alot :)