javascript - 在 Firefox/Chrome 上使用 ion.sound 听不到任何声音

标签 javascript google-chrome firefox audio plugins

我在使用插件时遇到问题,即使代码很简单,我的浏览器似乎也无法播放任何内容:(

  • 一些背景:
    • 计算机是装有 Windows 10 的笔记本电脑
    • 浏览器为 Firefox 43.0.4 和 Chrome 48.smthg

代码如下所示

  • 声音.js

    // init bunch of sounds
    ion.sound({
        sounds: [
            {
                name: "beer_can_opening",
                ended_callback: function () {
                    console.log("ended")
                },
                ready_callback: function () {
                    console.log("ready")
                }
            },
            {name: "bell_ring"},
            {name: "branch_break"},
            {name: "button_click"}
        ],
    
        // main config
        path: "sounds/",
        preload: true,
        multiplay: true,
        volume: 0.9,
        loop: 10
    });
    
    // play sound
    ion.sound.play("beer_can_opening");
    
  • index.html

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
        <script src="jquery-1.12.0.min.js"></script>
        <script src="ion.sound.min.js"></script>
        <script src="sounds.js"></script>
        <script src="sorcery.js"></script>
        <link type="text/css" rel="stylesheet" href="style.css"/>
        <meta lang="fr" xml:lang="fr" content="text/html;charset=UTF-8" http-equiv="Content-Type">
        <title>Sword & Sorcery</title>
    </head>
    
  • 最后,文件夹声音也出现了,beer_can_opening.aac/ogg/mp3。

  • 在两个浏览器的控制台中,无论我等多久,我都会“准备好”,但不会“结束”
  • 没有任何其他错误:(
  • 演示地址:http://ionden.com/a/plugins/ion.sound/en.html (就像作者发布的任何其他演示一样)效果很好

非常感谢,这个插件应该可以很好地完成工作,我真的很想使用它:)

最佳答案

这是一个自动播放错误。已在最新版本中修复:https://github.com/IonDen/ion.sound/issues/71

关于javascript - 在 Firefox/Chrome 上使用 ion.sound 听不到任何声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34981443/

相关文章:

javascript - FF Javascript 文本框样式问题

javascript - FusionCharts feedData 不是 AngularJS 中的函数

javascript - 将 ID 传递给 Angular JS 中的函数

javascript - 使用 jQueryeach 循环访问 API

javascript - Webextension 内联安装 chrome.runtime.connect 问题

c# - 使用 .NET 访问 Google Chrome 检查元素

javascript - 为什么我在 Chrome 网上应用店中无法打开带有 html 按钮的选项卡?

firefox - 如何允许用户从我的网站安装 FireFox 扩展

php - 用php动态添加内容到div

javascript - 长时间运行函数的 DOM 刷新