【问题标题】:No sound from Web Audio in chrome (currentTime always 0)chrome 中的 Web 音频没有声音(currentTime 始终为 0)
【发布时间】:2016-12-29 04:24:14
【问题描述】:

我的平板电脑运行的是 Chrome 52.0.2743.98,但是当我转到 this Web Audio example page 时不会输出声音。

当我在控制台中检查音频上下文时,我可以看到currentTime 始终为 0。

粘贴以下代码from MDN 也不会产生声音:

var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var oscillator = audioCtx.createOscillator();
oscillator.type = 'square';
oscillator.frequency.value = 3000; // value in hertz
oscillator.connect(audioCtx.destination);
oscillator.start();

这两个示例在我装有 Chrome 52.0.2743.116 的笔记本电脑上运行良好。

如何让 Chrome 从 Web Audio API 输出声音?

【问题讨论】:

  • 这应该可以。示例页面适用于我在运行相同版本 Chrome 的手机上。

标签: javascript android google-chrome audio web-audio-api


【解决方案1】:

对于 Chrome Android,我记得只有在附加到用户交互(例如触摸或点击事件)时才会开始播放音频。另见https://bugs.chromium.org/p/chromium/issues/detail?id=178297

【讨论】:

  • WebAudio 目前没有这种方式限制,示例页面和代码 sn-p 只是使用 WebAudio。其他事情正在发生,但我不知道是什么。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-09-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多