How to create a youtube embedder?
I created a video hosting si开发者_StackOverflowte I would like to create a form on my site where you post the youtube embed code and the video is played in jw player on my site and gets added to playlist, what should I look for to create such form?
EDIT:
@Marc B:
okay sir, is there any tutorials out there or anything just to see how it works? I mean how to create the form? I have no problem using youtube player lol :D
<?
$yt_video = "http://www.youtube.com/watch?v=AfgdUfDgCq8"; //OR $yt_video = $_GET['id']; // http://www.youtube.com/watch?v=AfgdUfDgCq8
if (preg_match('%(?:youtube\.com/(?:user/.+/|(?:v|e(?:mbed)?)/|.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})%i', $yt_video, $match))
{
/* regex works with:
http://youtu.be/dQw4w9WgXcQ
http://www.youtube.com/embed/dQw4w9WgXcQ
http://www.youtube.com/watch?v=dQw4w9WgXcQ
http://www.youtube.com/?v=dQw4w9WgXcQ
http://www.youtube.com/v/dQw4w9WgXcQ
http://www.youtube.com/e/dQw4w9WgXcQ
http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
http://www.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ
http://www.youtube.com/?feature=player_embedded&v=dQw4w9WgXcQ
*/
$jw = <<< EOF
<script type='text/javascript' src='jwplayer.js'></script>
<div id='mediaspace'>This text will be replaced</div>
<script type='text/javascript'>
jwplayer('mediaspace').setup({
'flashplayer': 'http://player.longtailvideo.com/player.swf',
'file': '{$yt_video}',
'controlbar': 'bottom',
'width': '470',
'height': '320'
});
</script>
EOF;
echo $jw;
}else{
echo "invalid youtube video";
}
?>
Download jwplayer and change player.swf
and jwplayer.js
locations. GL :)
I think that youtube has a template for embeded videos.
精彩评论