jPlayer:不在Firefox上加载jPlayer.swf

时间:2012-09-22 17:38:38

标签: flash firefox firebug jplayer fallback

我使用WordPress和 Elegant Themes 套件中的主题“Gleam”构建了网站http://www.ordinarypeopleofficial.com。这个主题非常复杂。它大量使用JavaScript。它有一个名为 custom.js 的700个代码行长文件,它使用AJAX管理整个网站。

由于这个原因,我无法包含JavaScript代码来将jPlayer加载到PHP脚本中,但我需要将其放入单独的JavaScript文件中并从 custom.js 调用此文件。

custom.js 中,我添加了以下行,其中包含名为 chiama-player.js 的文件到<head>标记中:

var html_doc = document.getElementsByTagName('head').item(0);
var js = document.createElement('script');
js.setAttribute('language', 'javascript');
js.setAttribute('type', 'text/javascript');
js.setAttribute('src', "/wp-content/themes/Gleam/chiama-player.js");
html_doc.appendChild(js);

名为 chiama-player.js 的文件包含实例化jPlayer的代码:

$(document).ready(function() {
if(window.location.href=="http://www.ordinarypeopleofficial.com/#!/le-canzoni/" || window.location.href=="http://www.ordinarypeopleofficial.com/le-canzoni/"){
    $("#jp_container_1").css( { 'display': 'block' } );
    $("#jquery_jplayer_1").jPlayer( {
        ready: function () {
            $(this).jPlayer("setMedia", {
                m4a: "http://www.ordinarypeopleofficial.com/wp-content/themes/Gleam/shakeit.m4a",
            });
        },
        swfPath: "http://www.ordinarypeopleofficial.com/wp-content/themes/Gleam/jplayer",
        supplied: "m4a"
    });
}
else{
    $("#jp_container_1").css( { 'display': 'none' } );
}
});

问题: 一切都适用于支持M4A的浏览器。

问题来自Firefox。 Firefox不支持M4A,因此需要Flash后备才能运行。当我尝试在Firefox上加载页面时,我看到swfPath被正确识别(事实上,如果我改变路径并输入一些随机文本,我在 Net 小组)。

问题是请求GET Jplayer.swf永远不会得到结果,并且在没有获取文件的情况下继续加载数小时。

1 个答案:

答案 0 :(得分:0)

进入文件 custom.js ,在函数et_init_scripts()的末尾,我执行了以下步骤:

  1. 我删除了我写的行,所以我不再调用我的文件 chiama-player.js
  2. 我复制了文件 jquery.jplayer.min.js 的内容并粘贴了所有内容。 (我知道,这太可怕了,但确实有效。)
  3. 在这些行之后,我复制了 chiama-player.js 的内容(创建了jPlayer)。