【发布时间】:2015-02-08 23:06:04
【问题描述】:
我有一个网页index.php,其中包含指向sound.php 的链接。在sound.php 上,使用 SoundJS 播放声音。
当我从 sound.php 导航到 index.php 时,Google Chrome 通常(但并非总是)显示错误消息(“哇,快!”):
https://support.google.com/chrome/answer/95669?hl=en
我正在使用适用于 Mac OS 的 Chrome 40。不管我是使用链接还是浏览器的后退按钮。
这是我的代码:
sound.php 调用一个使用 SoundJS 的 JS 函数:
<script type="text/javascript">
var int = [0, 7];
prepareAudio();
</script>
只要我删除这段代码,浏览器就不会再崩溃了。
prepareAudio() 在外部文件中:
function prepareAudio() {
// Try WebAudio or HTMLAudio
createjs.Sound.initializeDefaultPlugins();
// Try flash otherwise
if (!createjs.Sound.isReady()) {
// Flash plug-in is not default
createjs.FlashPlugin.swfPath = "../audio/";
// Enable flash support
$.getScript("../../js/flashplugin-0.6.0.min.js");
// Prefer WebAudio over HTMLAudio. Prefer HTMLAudio over Flash.
createjs.Sound.registerPlugins([createjs.WebAudioPlugin, createjs.HTMLAudioPlugin, createjs.FlashPlugin]);
}
// Get audio files
var audioPath = "../audio/";
var manifest = [];
for (var i = 0; i< audioFiles.length; i++)
manifest.push({id: audioFiles[i], src: audioPath + audioFiles[i] + ".ogg"});
// Play audio
var queue = new createjs.LoadQueue();
createjs.Sound.alternateExtensions = ["mp3"];
queue.installPlugin(createjs.Sound);
queue.addEventListener("complete", function() {playTask(int);});
queue.loadManifest(manifest);
createjs.Sound.registerSounds(manifest, audioPath);
}
涉及更多代码。我使用
播放声音 createjs.Sound.play(mySound);
在 Chrome 和其他浏览器中可以正常播放音频。
【问题讨论】:
-
这听起来更像是 Chrome 处理声音设置的问题。 “哇,啪!”这样的问题是 Chrome 中的错误,并且会被认真对待,因此请在 Chromium 错误跟踪器中提交错误报告。
-
我能够在 Chrome 40 OSX 中使用 SoundJS Audio Test Suite 持续重现这一点,方法是开始一些循环声音,然后点击返回按钮。但是重新启动 Chrome 后,我无法再重现。这向我表明它可能与记忆有关。也许 Chrome 的 WebAudio GC 有一个崩溃错误?可能值得向他们提交错误。
-
这似乎已在 Chrome 40.0.2214.115 的最新版本中得到修复
标签: javascript google-chrome audio soundjs