# Sound loading/ index.html error

**URL:** https://discourse.processing.org/t/sound-loading-index-html-error/25087
**Category:** Libraries
**Tags:** homework
**Created:** [October 31, 2020, 11:18pm UTC](https://discourse.processing.org/t/sound-loading-index-html-error/25087 "2020-10-31T23:18:11Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![ucsduni](https://avatars.discourse-cdn.com/v4/letter/u/bb73d2/32.png) [@ucsduni](https://discourse.processing.org/u/ucsduni)
#### Post date: [October 31, 2020, 11:18pm UTC](https://discourse.processing.org/t/sound-loading-index-html-error/25087/1 "2020-10-31T23:18:12Z")

</div>

I am having an issue getting my canvas to load when I am using the preload function with a sound. The code is producing a output that just says “Loading…” I think this is an issue with my index.html, but I’ve been trying to fix it on my own with no luck.

```auto
let sound;
function preload(){
   play=loadSound("ADHD project1sound2")
}

function setup() {
  let cnv = createCanvas(100, 100);
  cnv.mousePressed(canvasPressed);
  background(220);
  text('tap here to play', 10, 20);
  play=loadSound("ADHD project1sound2")
  sound.play()
}

function canvasPressed(){
  sound.play();
}

```

```auto
<!DOCTYPE html>
<html lang="en">
  <head src="path/to/p5.sound.js">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/addons/p5.sound.min.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css">
    <meta charset="utf-8" />

  </head>
  <body>
    <script src="sketch.js"></script>
  </body>
</html>

```

---

<div class="post-metadata">

### Author: ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)
#### Post date: [November 1, 2020, 3:06am UTC](https://discourse.processing.org/t/sound-loading-index-html-error/25087/2 "2020-11-01T03:06:04Z")

</div>

I suspect you’re missing a file extension (.mp3, etc.) on your audio file path:

```auto
let sound;
function preload(){
   sound = loadSound("ADHD project1sound2.mp3");
   ...

```

Also, if you’re running the page without a web server (opening the HTML file directly in your browser), you’ll encounter a CORS error.

---

<div class="post-metadata">

### Author: ![ucsduni](https://avatars.discourse-cdn.com/v4/letter/u/bb73d2/32.png) [@ucsduni](https://discourse.processing.org/u/ucsduni)
#### Post date: [November 2, 2020, 3:51am UTC](https://discourse.processing.org/t/sound-loading-index-html-error/25087/3 "2020-11-02T03:51:10Z")

</div>

if the .mp3 is added I receive this error code: “Uncaught TypeError: Cannot read property ‘play’ of undefined (sketch: line 12)”

---

<div class="post-metadata">

### Author: ![tabreturn](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tabreturn/32/3697_2.png) [@tabreturn](https://discourse.processing.org/u/tabreturn)
#### Post date: [November 2, 2020, 4:31am UTC](https://discourse.processing.org/t/sound-loading-index-html-error/25087/4 "2020-11-02T04:31:33Z")

</div>

Did you change `play` to `sound`?

```auto
   ...
   //play = loadSound("ADHD project1sound2.mp3");
   sound = loadSound("ADHD project1sound2.mp3");
   ...

```

---

<div class="post-metadata">

### Author: ![ucsduni](https://avatars.discourse-cdn.com/v4/letter/u/bb73d2/32.png) [@ucsduni](https://discourse.processing.org/u/ucsduni)
#### Post date: [November 2, 2020, 4:34am UTC](https://discourse.processing.org/t/sound-loading-index-html-error/25087/5 "2020-11-02T04:34:10Z")

</div>

omg you are the best thank you so much!!! Of course it was the dumb error that got me:)
