Skip to content
New issue

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

DEMO的音频播放不了 #2

Open
weathon opened this issue Apr 21, 2019 · 2 comments
Open

DEMO的音频播放不了 #2

weathon opened this issue Apr 21, 2019 · 2 comments

Comments

@weathon
Copy link

weathon commented Apr 21, 2019

No description provided.

@margox
Copy link
Owner

margox commented Apr 23, 2019

音频资源挂了

@csdudu
Copy link

csdudu commented May 22, 2024

音频资源没挂,报错: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(); };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants