Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript soundmanager2.js+;require.js不适用于firefox+;广告拦截增强版_Javascript_Html_Flash_Requirejs_Soundmanager2 - Fatal编程技术网

Javascript soundmanager2.js+;require.js不适用于firefox+;广告拦截增强版

Javascript soundmanager2.js+;require.js不适用于firefox+;广告拦截增强版,javascript,html,flash,requirejs,soundmanager2,Javascript,Html,Flash,Requirejs,Soundmanager2,启用AdBlock Plus后,无法使用Firefox 22.0进行以下测试。当我禁用adblock时,在Chrome+上可以正常工作。当我用脚本标签而不是requirejs加载脚本时,它也可以工作 ./index.html: <!DOCTYPE html> <html> <head> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"> <link

启用AdBlock Plus后,无法使用Firefox 22.0进行以下测试。当我禁用adblock时,在Chrome+上可以正常工作。当我用脚本标签而不是requirejs加载脚本时,它也可以工作

./index.html:

<!DOCTYPE html>
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">

<link rel="stylesheet" type="text/css" href="css/main.css"/>
<!--<link rel="icon" type="image/png" href="img/icon.png"/>-->

<!--<script  src="js/lib/jquery.js"></script>-->

<script data-main="js/main" src ="require.js"></script>
<!--
<script src="js/lib/soundmanager2.js"></script>
<script src="js/test.js"></script>
-->

<title></title>
</head>


<body>

<div id="stop" style="cursor:pointer;"> stop</div>

</body>


</html>

控制台中没有错误或任何东西,初始“hep”之后没有警报一个。

经典模式,与问题斗争数小时,放弃并寻求帮助,发布后立即找到解决方案

增加

在soundManager.setup()之后,它现在可以工作。

使用RequireJS的require()方法加载模块。在回调中编写您需要的代码。请注意,函数的参数是一个数组,其中包含加载依赖项的路径

require.config({
paths:{
    jquery:"lib/jquery",
    underscore:"lib/underscore",
    soundmanager2:"lib/soundmanager2"
    /*backbone:"lib/backbone",
    detectmobilebrowser:"lib/detectmobilebrowser"*/
},
shim: {
    'underscore': {
        exports: '_'
    },
    'soundmanager2':{
        exports:"soundManager"
    }
}
});


require(['jquery','underscore',"soundmanager2"],function($,_,soundManager){    
    alert("hep");
    window.soundManager=soundManager;
    soundManager.setup({
        url: 'swf',
        useHTML5Audio:true,
    preferFlash: false, // prefer 100% HTML5 mode, where both supported
    onready: function() {

        alert('SM2 ready!');
        /*
        soundManager.createSound({
            id: 'mySound',
            url: './test/test.mp3',
            autoLoad: true,
            autoPlay: false,
            onload: function() {
                soundManager.play('mySound');
            },
            volume: 50
        });
        */


    },
    ontimeout: function() {
        alert('SM2 init failed!');
    },
    defaultOptions: {
        // set global default volume for all sound objects
        volume: 100
    }
    });

    $("#stop").on("click",function(){
        alert("stop");
        soundManager.stop("mySound");
    });


});
soundManager.beginDelayedInit();
require.config({
paths:{
    jquery:"lib/jquery",
    underscore:"lib/underscore",
    soundmanager2:"lib/soundmanager2"
    /*backbone:"lib/backbone",
    detectmobilebrowser:"lib/detectmobilebrowser"*/
},
shim: {
    'underscore': {
        exports: '_'
    },
    'soundmanager2':{
        exports:"soundManager"
    }
}
});


require(['jquery','underscore',"soundmanager2"],function($,_,soundManager){    
    alert("hep");
    window.soundManager=soundManager;
    soundManager.setup({
        url: 'swf',
        useHTML5Audio:true,
    preferFlash: false, // prefer 100% HTML5 mode, where both supported
    onready: function() {

        alert('SM2 ready!');
        /*
        soundManager.createSound({
            id: 'mySound',
            url: './test/test.mp3',
            autoLoad: true,
            autoPlay: false,
            onload: function() {
                soundManager.play('mySound');
            },
            volume: 50
        });
        */


    },
    ontimeout: function() {
        alert('SM2 init failed!');
    },
    defaultOptions: {
        // set global default volume for all sound objects
        volume: 100
    }
    });

    $("#stop").on("click",function(){
        alert("stop");
        soundManager.stop("mySound");
    });


});