VideoJS 和 swfobject 嵌入问题

发布于 2024-10-12 14:07:44 字数 2062 浏览 4 评论 0原文

我正在使用 VideoJSSWFObject 用于嵌入视频。这个想法是,VideoJS 将尝试使用 HTML5 视频标签,如果不支持,将回退到 Flash。我正在尝试使用 SWFObject 嵌入 Flash 以用作后备。相关代码如下:

<ul id="client_gallery">
<% if PortfolioMedia %>
    <% control PortfolioMedia %>
    <% if VideoFile %>
        <li style="width:{$VideoWidth}px;height:{$VideoHeight}px">
            <div class="video-js-box">
                <video class="video-js" width="$VideoWidth" height="$VideoHeight" controls preload>
                    <source src="$VideoFile.URL" type="video/mp4" />
                    <div id="flash_player"></div>
                    <script type="text/javascript">
                    var flashvars = {
                        'file': "$VideoFile.URL"
                    };

                    var params = {
                        'allowfullscreen': "true",
                        "wmode": "transparent"
                    };

                    var attr = {
                        'id': 'f_player',
                        'name': 'f_player'
                    };

                    swfobject.embedSWF('/portfolio/javascript/jwplayer/player.swf', 'flash_player', '$VideoWidth', '$VideoHeight', '9', '', flashvars, params, attr, function(e){
                    });
                    </script>
                </video>
            </div>
        </li>
        <% end_if %>
    <% end_control %>
<% end_if %>
<script type="text/javascript">
    $(function(){
        VideoJS.setupAllWhenReady();
    });
</script>
</ul>

另一个表示法来自 CMS Silverstripe,与本期无关。这在 Chrome、Safari 和 IE 中工作正常,但在 Firefox 中不行。在 Firefox 中,我得到的只是一个空容器,就好像它试图使用 标签但无法加载兼容的源一样。

它根本没有嵌入 Flash,而且我知道 swfobject 代码正在工作,因为如果我只使用 swfobject 代码,而不是在 标记内,它就可以完美工作。所以问题是:VideoJS 不会回退到 swfobject 嵌入的代码。但为什么?

I'm using VideoJS and SWFObject to embed videos. The idea is that VideoJS will try to use the HTML5 video tag and will fallback on Flash if it is not supported. I'm trying to use SWFObject to embed the Flash to use as fallback. Here's the relevant code:

<ul id="client_gallery">
<% if PortfolioMedia %>
    <% control PortfolioMedia %>
    <% if VideoFile %>
        <li style="width:{$VideoWidth}px;height:{$VideoHeight}px">
            <div class="video-js-box">
                <video class="video-js" width="$VideoWidth" height="$VideoHeight" controls preload>
                    <source src="$VideoFile.URL" type="video/mp4" />
                    <div id="flash_player"></div>
                    <script type="text/javascript">
                    var flashvars = {
                        'file': "$VideoFile.URL"
                    };

                    var params = {
                        'allowfullscreen': "true",
                        "wmode": "transparent"
                    };

                    var attr = {
                        'id': 'f_player',
                        'name': 'f_player'
                    };

                    swfobject.embedSWF('/portfolio/javascript/jwplayer/player.swf', 'flash_player', '$VideoWidth', '$VideoHeight', '9', '', flashvars, params, attr, function(e){
                    });
                    </script>
                </video>
            </div>
        </li>
        <% end_if %>
    <% end_control %>
<% end_if %>
<script type="text/javascript">
    $(function(){
        VideoJS.setupAllWhenReady();
    });
</script>
</ul>

The other notation is from the CMS Silverstripe, which is irrelevant in this issue. This works fine in Chrome, Safari, and IE but not in Firefox. In Firefox all I get is an empty container, as if it was trying to use the <video> tag but couldn't load a compatible source.

It is not embedding Flash at all, and I know the swfobject code is working because if I use just the swfobject code, not within the <video> tag, it works perfectly. So the problem is: VideoJS won't fallback to code embedded by swfobject. But why?

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

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

发布评论

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

评论(1

伴梦长久 2024-10-19 14:07:44

videojs 已经内置了 Flash 支持作为后备。如果您想使用自己的 Flash 播放器,您可以在选项中更改它,例如:

<script type="text/javascript">
  VideoJS.options.flash.swf = "pathtoyourplayer.swf";
  VideoJS.options.flash.flashVars = {youroptions};
  VideoJS.options.flash.params = {youtparams};
  VideoJS.options.flash.attributes = {yourattributes};
</script>

..

<video ...>
  <source src=".." type="video/mp4" />
</video>

附加:swfObject 已包含在 videojs 中。

videojs already ha a build in flash support build in as fallback. If you want to use your own flash player you can change it in the options for example:

<script type="text/javascript">
  VideoJS.options.flash.swf = "pathtoyourplayer.swf";
  VideoJS.options.flash.flashVars = {youroptions};
  VideoJS.options.flash.params = {youtparams};
  VideoJS.options.flash.attributes = {yourattributes};
</script>

..

<video ...>
  <source src=".." type="video/mp4" />
</video>

additional: swfObject is already in videojs included.

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