1

我有一个网站,我一直在努力,我们有一个 iframe,可以从给定的 YouTube 频道中提取最新视频。它在可以运行闪存的桌面或设备上运行良好,但是当用户在 IOS 设备或某些 android 设备上时,什么都不会显示在那里。它是一个空旷的广场。有没有人知道的好解决方法或我可以解决这个问题的方法?我尝试检测它是否是移动平台并改为显示填充图像,但仍无法在所有设备上运行。任何建议都会很棒。

我也确实考虑过使用 YouTube API 并获取视频的图像并显示然后用户单击它只会将您带到视频,这将是一个修复,但最后的修复。

此外,如果有人有更好的代码工作方式,那么我在下面的 id 喜欢看到它!

<div class="span6 data_video">
    <?php
        $url = 'http://gdata.youtube.com/feeds/api/users/'. $Youtube .'/uploads?max-results=1';
        $xml = simplexml_load_file($url);
        foreach ($xml->entry as $entry) :

            // get nodes using mrss ('media' rss namespace)
            $kids = $entry->children('http://search.yahoo.com/mrss/');

            // for the embed src (just the flv location - you'll need to print out the rest of the object/embed tag
            $attributes = $kids->group->content[0]->attributes();
            $flv = $attributes['url'];

        endforeach; 
    ?>
    <iframe align="left" width="100%" height="315" src="<?php echo $flv; ?>" frameborder="0" allowfullscreen></iframe>
</div>

检测移动浏览器即时使用的代码只是http://detectmobilebrowsers.com/

4

1 回答 1

0

取自 Drewid 在另一个 stackoverflow 帖子中...

var hasFlash = false;
try {
  var fo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
  if(fo) hasFlash = true;
}catch(e){
  if(navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) hasFlash = true;
}

您还可以通过将 url var ?html5=1 添加到 iframe 地址来通过 html 5 流式传输 youtube

于 2013-08-29T20:35:23.537 回答