Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
音频资源挂了
音频资源没挂,报错:The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. 这个错误提示是因为浏览器的安全策略限制了在没有用户交互的情况下自动播放音频。要解决这个问题,在用户与页面进行交互后(例如点击按钮)再创建或恢复 AudioContext。我修改了一下“播放音乐”那个按钮的行为,在那里弄了个条件初始化,问题就解决了。 const my_play = document.querySelector(".my_play"); my_play.addEventListener("click", () => { if(!vudio){ init() } audio.play() }); const init = () => { console.log('#init#') vudio = new Vudio(audio, canvas, { effect: "waveform", accuracy: 128, width: 1024, height: 600, waveform: { maxHeight: 300, minHeight: 1, // 最小波形高度 spacing: 1, // 波形间隔 color: [ [0, "#f00"], [0.3, "#f00"], [0.3, "#f90"], [0.7, "#f90"], [0.7, "#ff0"], [1, "#ff0"], ], }, }); vudio.dance(); };
const my_play = document.querySelector(".my_play"); my_play.addEventListener("click", () => { if(!vudio){ init() } audio.play() }); const init = () => { console.log('#init#') vudio = new Vudio(audio, canvas, { effect: "waveform", accuracy: 128, width: 1024, height: 600, waveform: { maxHeight: 300, minHeight: 1, // 最小波形高度 spacing: 1, // 波形间隔 color: [ [0, "#f00"], [0.3, "#f00"], [0.3, "#f90"], [0.7, "#f90"], [0.7, "#ff0"], [1, "#ff0"], ], }, }); vudio.dance(); };
No description provided.
The text was updated successfully, but these errors were encountered: