2013-02-24 142 views
0

在我的网站上,我尝试显示一些youtube视频。在数据库中,我有YouTube视频上的地址,我正在尝试在我的网站上显示它。问题是,当平板电脑访问网站时,此代码不起作用。嵌入式youtube视频不能在Android上播放

我不知道为什么,也不知道如何调试问题。

<?php  
// url of video 
$url = $data['video']; 

// we get the unique video id from the url by matching the pattern 
preg_match("/v=([^&]+)/i", $url, $matches); 
$id = $matches[1]; 

// template for generating embed codes 
$code = '<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/{id}&hl=en_US&fs=1&"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/{id}&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>'; 

// replace each {id} with the actual ID of the video to get embed code 
$code = str_replace('{id}', $id, $code); 

if(isset($id)&& $id !== '') { 
    echo $code; 
} 
?> 

你能帮助我做一些指点?

+1

'TYPE =“应用程序/ x - 冲击波闪光”'。 Flash在移动设备上无用。很少有人支持它,甚至更少的人甚至安装它。 – 2013-02-24 20:59:06

回答

2

您使用的嵌入代码是超古代<object>版本。使用最新的YouTube 基于嵌入,而不是它应该工作在更多的移动设备:

$code = '<iframe width="425" height="344" src="http://www.youtube.com/embed/{id}" frameborder="0" allowfullscreen></iframe>'; 
+0

thx评论:) – Eugen 2013-02-24 21:20:57

相关问题