Scripts
video embed / insluiten
Dit script geeft je de mogelijkheid om een video url in te voeren en en dan word automatisch de embed/insluit code gegenereerd ik heb dit script op internet gevonden maar het was out-dated dus ik heb het geupdate en werkt nu weer volledig
voorbeeld.php
[code]<?php
include('embed.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test site</title>
</head>
<body>
<?php
//gewoon een video
$video=new video_embed();
$video->embed("video url" , "typ het woord 'play' voor autoplay zonder '' ");
?>
<?php
//meerdere videos
$video=new video_embed();
$video->embed("http://youtube.com/watch?v=MgV0PjNw3Qw" , "play");
$video->embed("http://video.google.com/videoplay?docid=-6511716987227605917" , "play");
$video->embed("http://one.revver.com/watch/421951");
$video->embed("http://one.revver.com/watch/421951/flv");
$video->embed("http://www.metacafe.com/watch/854726/photoshop_match_color_simple_and_amazing_results/");
$video->embed("http://www.liveleak.com/view?i=f23792e462");
$video->embed("http://www.liveleak.com/view?i=f23792e462&p=1", "play");
?>
</body>
</html>[/code]
embed.php
<?php
class video_embed{
function embed($raw, $auto)
{
//raw data schoonmaken
$raw = trim($raw);
//check auto play
//de vershillende hosts gebruikt van een host http:// en http://www. om te zorgen dat hij werkt
$hosts = array("http://youtube.com/watch?v=", "http://www.youtube.com/watch?v=", "http://video.google.com/videoplay?docid=-", "http://www.video.google.com/videoplay?docid=-",
"http://one.revver.com/watch/", "http://www.one.revver.com/watch/", "http://www.metacafe.com/watch/", "http://metacafe.com/watch/", "http://www.liveleak.com/view?i=", "http://liveleak.com/view?i=");
$code = str_replace($hosts, "", $raw);
//host zoeken
$host1 = strpos($raw, "youtube.com", 1);
$host2 = strpos($raw, "video.google.com", 1);
$host3 = strpos($raw, "one.revver.com", 1);
$host4 = strpos($raw, "www.metacafe.com", 1);
$host5 = strpos($raw, "www.liveleak.com", 1);
if($host1 != null) {$host .= "youtube";}
if($host2 != null) {$host .= "google";}
if($host3 != null) {$host .= "revver";}
if($host4 != null) {$host .= "metacafe";}
if($host5 != null) {$host .= "liveleak";}
//error
if($host != "youtube" && $host != "google" && $host != "revver" && $host != "metacafe" && $host != "liveleak")
{
$error = true;
echo "Error Embedding<br/>";
}
if($host == "youtube")
{
//autoplay
$you_auto = "";
if($auto == "play") { $you_auto = "&autoplay=1"; }
echo "
<object width='425' height='353'><param name='movie' value='http://www.youtube.com/v/$code$you_auto'></param>
<param name='wmode' value='transparent'></param>
<embed src='http://www.youtube.com/v/$code$you_auto' type='application/x-shockwave-flash' wmode='transparent' width='425' height='353'>
</embed></object><br/>";
}
if($host == "google")
{
//autoplay
$google_auto = "";
if($auto == "play") { $google_auto = "&autoPlay=true"; }
echo "
<embed style='width:400px; height:326px;' id='VideoPlayback' type='application/x-shockwave-flash'
src='http://video.google.com/googleplayer.swf?docId=-$code$google_auto&hl=en' flashvars=''></embed><br/><br/>";
}
if($host == "revver")
{
//code
$code = str_replace("/flv", "", $code);
//autoplay
$rev_auto = "";
if($auto == "play") { $rev_auto = "&autoStart=true"; }
echo "<script src='http://flash.revver.com/player/1.0/player.js?mediaId:$code;affiliateId:0;height:392;width:480;' type='text/javascript'>
</script><br/>";
}
if($host == "metacafe")
{
//code
$code = strrev($code);
$code = trim($code, "/");
$code = strrev($code);
echo "<embed src='http://www.metacafe.com/fplayer/$code.swf'
width='400' height='345' wmode='transparent' pluginspage='http://www.macromedia.com/go/getflashplayer'
type='application/x-shockwave-flash'> </embed><br/><br/>";
}
if($host == "liveleak")
{
//code
$code = str_replace("&p=1", "", $code);
echo "<object type='application/x-shockwave-flash' width='450' height='370'='transparent'
data='http://www.liveleak.com/player.swf?autostart=$live_auto&token=$code'>
<param name='movie' value='http://www.liveleak.com/player.swf?autostart=$live_auto&token=$code'>
<param name='wmode' value='transparent'><param name='quality' value='high'></object><br/><br/>";
}
//variablen
$raw = null;
$code = null;
$host = null;
}
}
?>
Reacties
0