# P5.Js sketch used to work but now it doesn't

**URL:** <https://discourse.processing.org/t/p5-js-sketch-used-to-work-but-now-it-doesnt/32524>\
**Category:** Libraries\
**Created:** [September 30, 2021, 1:18pm UTC](https://discourse.processing.org/t/p5-js-sketch-used-to-work-but-now-it-doesnt/32524 "2021-09-30T13:18:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alsumwas](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@alsumwas](https://discourse.processing.org/u/alsumwas)\
**Post date:** [September 30, 2021, 1:18pm UTC](https://discourse.processing.org/t/p5-js-sketch-used-to-work-but-now-it-doesnt/32524/1 "2021-09-30T13:18:44Z")

</div>

The sketch below worked a year ago but now when I try to play it it just says loading indefinitely. Any thoughts on what the hangup is?

\</var bgcolor;  
var abutton;  
var bbutton;  
var cbutton;  
var dbutton;  
var ebutton;  
var fbutton;

function preload () {  
bsong = loadSound(“[https://ia801401.us.archive.org/28/items/ME2020-09-15/magnolia2020-09-15d01t01.mp3](https://ia801401.us.archive.org/28/items/ME2020-09-15/magnolia2020-09-15d01t01.mp3)”);  
csong = loadSound(“[https://ia601402.us.archive.org/24/items/ds2020-09-24/02%20My%20Baby’s%20Coming%20Back%20To%20Me.mp3](https://ia601402.us.archive.org/24/items/ds2020-09-24/02%20My%20Baby%27s%20Coming%20Back%20To%20Me.mp3)”)  
}

function setup() {  
createCanvas(400, 400);  
bgcolor = color (200, 140, 160);

let acol = color(255, 213, 120, 100);

abutton = createButton (“Button A”);  
abutton.position(10, 10);  
abutton.mousePressed(changeColor);  
abutton.style(‘background-color’, acol);

let bcol = color(170, 123, 200, 100);

bbutton = createButton (“Button B”);  
bbutton.position(150, 10);  
bbutton.mousePressed(btogglePlaying);  
bbutton.style(‘background-color’, bcol);

let ccol = color(230, 210, 200, 100);

cbutton = createButton (“Button C”);  
cbutton.position(290, 10);  
cbutton.mousePressed(ctogglePlaying);  
cbutton.style(‘background-color’, ccol);

let dcol = color(240, 124, 160, 100)

dbutton = createButton (“Button D”);  
dbutton.position(10, 50);  
dbutton.mousePressed(changeColor);  
dbutton.style(‘background-color’, dcol);

let ecol = color(230, 224, 110, 100)

ebutton = createButton (“Button E”);  
ebutton.position(150, 50);  
ebutton.mousePressed(changeColor);  
ebutton.style(‘background-color’, ecol);

let fcol = color(160, 110, 160, 100)

fbutton = createButton (“Button F”);  
fbutton.position(290, 50);  
fbutton.mousePressed(changeColor);  
fbutton.style(‘background-color’, fcol);

}

function changeColor() {  
bgcolor = color(random(255), 140, 160);  
}

function btogglePlaying () {

if (bsong.isPlaying()) {  
bsong.stop();  
bbutton.html(“Button B”);  
}  
else {  
bsong.play();  
bbutton.html(“Stop”);  
}}

function ctogglePlaying () {

if (csong.isPlaying()) {  
csong.stop();  
cbutton.html(“Button C”);  
}  
else {  
csong.play();  
cbutton.html(“Stop”);  
}}

function draw() {  
background(bgcolor);

}

>

---

<div class="post-metadata">

**Author:** ![KumuPaul](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kumupaul/32/13072_2.png) [@KumuPaul](https://discourse.processing.org/u/KumuPaul)\
**Post date:** [September 30, 2021, 10:24pm UTC](https://discourse.processing.org/t/p5-js-sketch-used-to-work-but-now-it-doesnt/32524/2 "2021-09-30T22:24:04Z")

</div>

1. When you post code in this forum please use the `</>` icon in the formatting bar which surrounds your code with lines containing ``` for proper formatting.
2. This may be the result of not posting the code correctly, but your code appears to have special unicode “quotes” instead of standard ASCII quotes (`'`, `"`)
3. Always check the browsers JavaScript **Console** when a sketch is stuck loading

```nohighlight
Access to XMLHttpRequest at 'https://ia801401.us.archive.org/28/items/ME2020-09-15/magnolia2020-09-15d01t01.mp3' from origin 'https://preview.p5js.org' has been blocked by CORS policy:
    No 'Access-Control-Allow-Origin' header is present on the requested resource.

Access to XMLHttpRequest at 'https://ia601402.us.archive.org/24/items/ds2020-09-24/02%20My%20Baby's%20Coming%20Back%20To%20Me.mp3' from origin 'https://preview.p5js.org' has been blocked by CORS policy:
    No 'Access-Control-Allow-Origin' header is present on the requested resource.

```

This is happening because [archive.org](http://archive.org) is not allowing cross origin requests for these resources. You can read about [CORS here](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). You will need to download these items and store them somewhere that supports cross origin requests, or store them on the host that servers your webpage.

---

<div class="post-metadata">

**Author:** ![alsumwas](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@alsumwas](https://discourse.processing.org/u/alsumwas)\
**Post date:** [October 1, 2021, 12:32pm UTC](https://discourse.processing.org/t/p5-js-sketch-used-to-work-but-now-it-doesnt/32524/3 "2021-10-01T12:32:53Z")

</div>

Thanks!  
I am not sure I did the \</\> correctly. Also the quotes are correct in the original they just changed to unicode when I copy-pasted the code.
