# Sound won't work, AudioContext was not allowed to start?

**URL:** <https://discourse.processing.org/t/sound-wont-work-audiocontext-was-not-allowed-to-start/15921>\
**Category:** Libraries\
**Created:** [November 28, 2019, 8:24pm UTC](https://discourse.processing.org/t/sound-wont-work-audiocontext-was-not-allowed-to-start/15921 "2019-11-28T20:24:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![coledeushane](https://avatars.discourse-cdn.com/v4/letter/c/6bbea6/32.png) [@coledeushane](https://discourse.processing.org/u/coledeushane)\
**Post date:** [November 28, 2019, 8:24pm UTC](https://discourse.processing.org/t/sound-wont-work-audiocontext-was-not-allowed-to-start/15921/1 "2019-11-28T20:24:03Z")

</div>

I can’t seem to get the p5.sound.js to work correctly. The console error I keep getting is:  
p5.sound.js:819 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. [https://goo.gl/7K7WLu](https://goo.gl/7K7WLu)  
Tone.Context @ p5.sound.js:819  
(anonymous) @ p5.sound.js:992  
(anonymous) @ p5.sound.js:997  
(anonymous) @ p5.sound.js:73  
(anonymous) @ p5.sound.js:74  
p5.sound.js:1002 The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. [https://goo.gl/7K7WLu](https://goo.gl/7K7WLu)

---

<div class="post-metadata">

**Author:** ![manno](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@manno](https://discourse.processing.org/u/manno)\
**Post date:** [November 28, 2019, 8:28pm UTC](https://discourse.processing.org/t/sound-wont-work-audiocontext-was-not-allowed-to-start/15921/2 "2019-11-28T20:28:58Z")

</div>

I _think_ the user needs to interact with the page/canvas first before it is allowed to play audio.  
Just so that annoying pages don’t give un-expecting people heart attack by automatically playing audio 🙂

---

<div class="post-metadata">

**Author:** ![coledeushane](https://avatars.discourse-cdn.com/v4/letter/c/6bbea6/32.png) [@coledeushane](https://discourse.processing.org/u/coledeushane)\
**Post date:** [November 28, 2019, 9:13pm UTC](https://discourse.processing.org/t/sound-wont-work-audiocontext-was-not-allowed-to-start/15921/3 "2019-11-28T21:13:17Z")

</div>

I tried that and got hit with this ☹

p5.sound.js:1883 Access to XMLHttpRequest at ‘file:///C:/Users/coled/Documents/Programming/p5js/bubble%20sort/sounds/laser.mp3’ from origin ‘null’ has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

p5.sound.js:1880 There was no response from the server at sounds/laser.mp3. Check the url and internet connectivity.  
The error stack trace includes:  
loadSound

---

<div class="post-metadata">

**Author:** ![figraham](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/figraham/32/4161_2.png) [@figraham](https://discourse.processing.org/u/figraham)\
**Post date:** [November 29, 2019, 3:58am UTC](https://discourse.processing.org/t/sound-wont-work-audiocontext-was-not-allowed-to-start/15921/4 "2019-11-29T03:58:36Z")

</div>

I’d suggest running a local server that normally solves some problems. Normally browsers don’t do great loading files directly from the filesystem. [http-server through npm](https://www.npmjs.com/package/http-server) is super simple or live-server there too. I think there’s one through python too that I’ve heard a lot of people use.

None the less that still might not fix this particular error you can read more about it [on the Mozilla docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS/Errors). And [here is how to disable CORS for testing](https://pointdeveloper.com/how-to-bypass-cors-errors-on-chrome-and-firefox-for-testing/).
