I read a post that stated "I vaguely recall that Jeroen mentioned in a post that only the LQ video is available through the YouTube API."
Is this the case? I would like to use the High Quality videos from YouTube in my player.
I've read most of the "php" posts for the work around, but I am new to this code stuff and I can't seem to make heads or tails of it. I've tried a few things but don't really know where to start.
Thanks,
David
You need:
1) a host that allows you to execute PHP scripts,
2) place the YouTube script on your site,
3) call the YouTube script from the player or a playlist
YouTube_Multi-Format.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html lang="en">
<head>
<title>YouTube Multi-Format</title>
<script type="text/javascript" src="swfobject-2.2.js"></script>
<script type="text/javascript">
var flashvars =
{
// fmt=6 HQ FLV 480x360 fmt=18 HQ MP4 480x270 fmt=22 HQ MP4 1280x720 fmt=35 HQ MP4 640x360
//...Good Test Case
'file': encodeURIComponent('YouTube_Multi-Format.php?v=K2_U1kbIcJQ&fmt=18'),
'type': 'video',
'stretching': 'none',
'frontcolor': '86C29D',
'backcolor': '849BC1',
'lightcolor': 'C286BA',
'screencolor': '000000',
'autostart': 'true'
};
var params =
{
'allowfullscreen': 'true',
'allowscriptaccess': 'always',
'bgcolor': '#000000'
};
var attributes =
{
'name': 'playerId1',
'id': 'playerId1'
};
swfobject.embedSWF('player-4.3.132.swf', 'player1', '480', '290', '9.0.124', false, flashvars, params, attributes);
</script>
</head>
<body>
<div id="playercontainer1" class="playercontainer1">
<a id="player1" class="player1" href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash">Get the Adobe Flash Player to see this video.</a>
</div>
</body>
</html>
YouTube_Multi-Format.php
<?php// call with: http://www.mydomain.com/path/YouTube_Multi-Format.php?v=K2_U1kbIcJQ&fmt=18
// 'file': encodeURIComponent('YouTube_Multi-Format.php?v=K2_U1kbIcJQ&fmt=18'),
// 'type': 'video',
// fmt=6 HQ FLV 480x360
// fmt=18 HQ MP4 480x270
// fmt=22 HQ MP4 1280x720
// fmt=35 HQ MP4 640x360
$videoid = (isset($_GET['v'])) ? strval($_GET['v']) : 'K2_U1kbIcJQ';
$fmt = (isset($_GET['fmt'])) ? intval($_GET['fmt']) : '';
$uri = "http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=$videoid";
$t = trim(strip_tags(@file_get_contents($uri)));
$uri = "http://www.youtube.com/get_video.php?video_id=$videoid&t=$t&fmt=$fmt";
//...debug
/*
$headers = get_headers($uri);
print "<pre>\n";
print "URI: $uri\n" ;
print_r($headers);
print "\n</pre>\n";
exit;
*/
//...debug
header("Location: $uri");
?>