Web Audio API no sound playing

2019-02-19 04:43发布

问题:

I'm trying to get into the Web Audio API as I'm looking to make some visualizations based on the music that's playing. However all examples I have found, it's like the audio is muted. It plays the file but there's no sound.

For example: codepen.io/noeldelgado/pen/jqibm

Even following this - https://www.youtube.com/watch?v=IBHpSkGZtNM yields same result.

I'm on mac, using the latest version of Chrome (42.0.2311.90), have also tried on latest Firefox and it's the same problem.

回答1:

It's a cross-origin access issue in createMediaElementSource that landed in Chrome 42. You need to setup the appropriate headers for the ogg files and set the crossOrigin attribute. Otherwise you get no audio output at all.