首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jPlayer:没有在火狐上加载jPlayer.swf

jPlayer:没有在火狐上加载jPlayer.swf
EN

Stack Overflow用户
提问于 2012-09-22 17:38:38
回答 1查看 1.5K关注 0票数 0

我创建了http://www.ordinarypeopleofficial.com网站WordPress和主题“格莱姆”的套房优雅的主题。这个主题非常复杂。它大量使用JavaScript。它有700个代码行长的文件,名为custom.js,它使用AJAX管理整个网站。

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

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

代码语言:javascript
复制
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的代码:

代码语言:javascript
复制
$(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上。火狐不支持M4A,所以它需要fallback才能工作。当我试图在火狐上加载页面时,我看到swfPath是正确识别的(实际上,如果我更改路径并键入一些随机文本,我就会在网络面板中看到404 )。

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-08-28 16:54:16

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

  1. 我删除了我写的行,所以我不再调用我的文件chiama-player.js了。
  2. 我复制了文件jquery.jplayer.min.js的内容,并将其全部粘贴。(我知道,这很可怕,但很管用。)
  3. 在这些行之后,我复制了chiama-player.js的内容(它创建了jPlayer)。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12546173

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档