“不允许启动 AudioContext”在 React 中使用 useSound hook 时发出警告

问题描述

所以我使用 useSound 钩子。但它在以下简单示例中不起作用:

import useSound from 'use-sound';

import boopSfx from '../../sounds/boop.mp3';

const BoopButton = () => {
  const [play] = useSound(boopSfx);

  return <button onClick={play}>Boop!</button>;
};

我在控制台收到以下警告:

howler.js:2500 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)