我怎么说“你需要安装闪存...”对于嵌入的 YouTube 剪辑(如果用户没有 flash 或 html5)

发布于 2024-09-09 22:02:35 字数 2385 浏览 6 评论 0原文

我使用以下代码在我的网站上嵌入 youtube 剪辑:

<object width="259" height="215"  style="margin:auto; width:262px; height:217px; position:relative;">
    <param name="movie" value="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1"></param>
    <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
    <embed src="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="259" height="215"></embed>
</object>
<p style="margin-top:12px; width: 259px; text-align:center;"><?php echo $yt_title; ?></p>

这在配备 html5 或配备 flash 的浏览器中效果很好。但是,如果我尝试在未安装 Flash 的情况下使用 IE 7/8,则会得到以下占位符:

替代文字

如何获得“此视频需要 flash 播放器”?


更新:这是我使用 Richard JP Le Guen 的解决方案的最终代码。它工作完美。

<object width="259" height="215"  style="margin:auto; width:262px; height:217px; position:relative;">
    <param name="movie" value="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1" />
    <param name="wmode" value="opaque" />
    <!--[if !IE]>-->
        <object type="application/x-shockwave-flash" data="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1" allowfullscreen="true" width="259" height="215">
            <param name="wmode" value="opaque" />
            <!--<![endif]-->
            <a href="http://www.adobe.com/go/getflashplayer" style="display: block; text-align:center; padding-top:40px;">
                <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
            </a>
            <!--[if !IE]>-->
        </object>
    <!--<![endif]-->
</object>

I'm embedding youtube clips on my site with the following code:

<object width="259" height="215"  style="margin:auto; width:262px; height:217px; position:relative;">
    <param name="movie" value="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1"></param>
    <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
    <embed src="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="259" height="215"></embed>
</object>
<p style="margin-top:12px; width: 259px; text-align:center;"><?php echo $yt_title; ?></p>

which works great in html5 equipped or flash equipped browsers. However, if i try using IE 7/8 without flash installed, i get this placeholder:

alt text

how can i get a "this video requieres flash player" instead?


update: this is my final code using Richard JP Le Guen's solution. it works perfectly.

<object width="259" height="215"  style="margin:auto; width:262px; height:217px; position:relative;">
    <param name="movie" value="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1" />
    <param name="wmode" value="opaque" />
    <!--[if !IE]>-->
        <object type="application/x-shockwave-flash" data="http://www.youtube.com/v/<?php echo $yt_id; ?>&hl=en&fs=1&rel=0&hl=en&fs=1&rel=0&showinfo=0&autoplay=1" allowfullscreen="true" width="259" height="215">
            <param name="wmode" value="opaque" />
            <!--<![endif]-->
            <a href="http://www.adobe.com/go/getflashplayer" style="display: block; text-align:center; padding-top:40px;">
                <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
            </a>
            <!--[if !IE]>-->
        </object>
    <!--<![endif]-->
</object>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时间你老了 2024-09-16 22:02:35

这看起来像是 SWFObject 的用途。

借助 SWFObject,您可以使用 JavaScript 动态添加 。在您的(正常的、符合标准的)HTML 中,您将收到类似“您需要 Flash 和 JavaScript 才能观看此视频”的消息,然后使用 SWFObject 将该内容替换为视频。

通过 Google 快速搜索 SWFObject 和 YouTube,找到了本文。我没有时间阅读它,但看起来它会有所帮助。

This looks like the sort of thing one uses SWFObject for.

With SWFObject, you add the <object> and <embed> dynamically, using JavaScript. In your (normal, standards-compliant) HTML you would have a message like "You need Flash and JavaScript to view this video" and then use SWFObject to swap out that content for the video.

A quick Google search for SWFObject and YouTube yielded this article. I don't have time to read it, but it looks like it could help.

月棠 2024-09-16 22:02:35

YouTube 使用 标签:

 <embed>blah</embed>
 <noembed>
    <div class="yt-alert yt-alert-error yt-alert-player yt-rounded">
      <img src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="icon master-sprite" alt="Alert icon">
      <div class="yt-alert-content"> You need Adobe Flash Player to watch this video. <br> <a href="http://get.adobe.com/flashplayer/">Download it from Adobe.</a> 
      </div>
    </div>
  </noembed>

虽然我不认为它属于任何官方标准...

编辑:添加了 标记到示例,以显示 YouTube 正在做什么。

YouTube uses a <noembed> tag:

 <embed>blah</embed>
 <noembed>
    <div class="yt-alert yt-alert-error yt-alert-player yt-rounded">
      <img src="http://s.ytimg.com/yt/img/pixel-vfl73.gif" class="icon master-sprite" alt="Alert icon">
      <div class="yt-alert-content"> You need Adobe Flash Player to watch this video. <br> <a href="http://get.adobe.com/flashplayer/">Download it from Adobe.</a> 
      </div>
    </div>
  </noembed>

Although I do not think it belongs to any official standard...

Edit: Added <embed> tag to example, to show what YouTube is doing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文