
Play dailymotion example
I made a little example how to play a single HD video from dailymotion
bc.. //Single Dailymotion video with the JW player
//EXAMPLE
//http://www.dailymotion.com/video/x2q0rp_amy-winehouse-stronger-than-me_music
//$videocode will be x2q0rp_amy-winehouse-stronger-than-me_music or use just this code x2q0rp
$videocode = 'x2q0rp_amy-winehouse-stronger-than-me_music';
// set video data feed URL
$feedURL = 'http://www.dailymotion.com/atom/video/' . $videocode;
// read feed into SimpleXML object
if(!$sxml = @simplexml_load_file($feedURL))
{
echo '<div style="width:470px; height:320px;border: 1px solid #000;">No connection to the Dailymotion server or a wrong url !</div>';
return;
}
// Find out the link to the first FLV
$linksurl = $sxml->entry->children('http://www.w3.org/2005/Atom');
$linkproperties = array('enclosure');
foreach($linkproperties as $content){
$$content = null;
$exit = false;
foreach($linksurl as $links) {
if($exit){
continue;
}
foreach($links->attributes() as $keys => $values) {
if($keys == 'href'){
$$content = (string) $values;
}
if (stristr ($values , $content) == TRUE) {
$exit = true;
}
}
}
if(!$exit){
$$content = null;
}
}
?>
<div id="player">This text will be replaced</div>
<script type="text/javascript">
var so = new SWFObject('http://www.longtailvideo.com/jw/embed/player.swf','mpl','470','320','9');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addParam('flashvars','&file=<?=$enclosure; ?>&autostart=true&stretching=fill');
so.write('player');
</script>