现在我正在使用这段代码来播放youtube视频。
<?php
// Replace Youtube URLs with embed code
function embedYoutube($text)
{
$search = '% # Match any youtube URL in the wild.
(?:https?://)? # Optional scheme. Either http or https
(?:www\.)? # Optional www subdomain
(?: # Group host alternatives
youtu\.be/ # Either youtu.be,
| youtube\.com # or youtube.com
(?: # Group path alternatives
/embed/ # Either /embed/
| /v/ # or /v/
| /watch\?v= # or /watch\?v=
) # End path alternatives.
) # End host alternatives.
([\w\-]{10,12}) # Allow 10-12 for 11 char youtube id.
\b # Anchor end to word boundary.
%x';
$replace = '<object width="425" height="344">
<param name="movie" value="http://www.youtube.com/v/$1?fs=1"</param>
<param name="allowFullScreen" value="true"></param>
<param name="allowScriptAccess" value="always"></param>
<embed src="http://www.youtube.com/v/$1?fs=1"
type="application/x-shockwave-flash" allowscriptaccess="always" width="425" height="344">
</embed>
</object>';
return preg_replace($search, $replace, $text);
}
$string = 'This is the forum post content with some Youtube links:'."\n".
'http://www.youtube.com/watch?v=NLqAF9hrVbY'."\n".
'http://www.youtube.com/v/u1zgFlCw8Aw?fs=1&hl=en_US';
echo embedYoutube($string);
?>但这些视频不能在全屏模式下播放,因为这些嵌入式代码不会显示视频的任何信息,也不会显示视频的拍摄地点。
例如:http://www.youtube.com/watch?v=YR12Z8f1Dh8展示带有标题的全屏选项的视频为什么这个Kolaveri Di全歌推广视频在HD youtube.com中
和描述像Chinna惊喜检查独家视频拍摄的歌曲录制期间与音乐作曲家Anirudh,Dhanush,Shruti Hassan,Aishwarya和音响工程师Sivakumar
就像facebook一样。
如何做到这一点,任何人都有答案。
发布于 2011-12-08 13:43:33
尝试,在embed属性中输入allowFullScreen="true"
为了获得像description这样的其他视频信息,你必须使用youtube data api,Reference Guide: Data API Protocol
您可以使用curl从您的服务器端获取信息。
https://stackoverflow.com/questions/8426627
复制相似问题