# Loading Large Sound Files- problem with loading SOLVED!

**URL:** <https://discourse.processing.org/t/loading-large-sound-files-problem-with-loading-solved/21351>\
**Category:** Libraries\
**Created:** [May 27, 2020, 7:13pm UTC](https://discourse.processing.org/t/loading-large-sound-files-problem-with-loading-solved/21351 "2020-05-27T19:13:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kris1](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kris1/32/9385_2.png) [@Kris1](https://discourse.processing.org/u/Kris1)\
**Post date:** [May 27, 2020, 7:13pm UTC](https://discourse.processing.org/t/loading-large-sound-files-problem-with-loading-solved/21351/1 "2020-05-27T19:13:46Z")

</div>

I am having problems loading a large sound file. It is too large to be uploaded directly to the P5js editor.  
I have tried linking it to my dropbox, this has failed.  
I have tried both load sound, and new p5.SoundFile (ensuring the index code has the library link included).  
The drop box link is correct. My internet is running very fast. I have tried the code in both Chrome and Firefox. Both times it failed.

The error I receive is

There was no response from the server at [https://www.dropbox.com/preview/mySong.mp3](https://www.dropbox.com/preview/mySong.mp3). Check the url and internet connectivity.

Code below-it is just to test getting a file loaded so very basic

````auto
type or paste code here
```let song;

// function preload(){
// song = loadSound('https://www.dropbox.com/preview/mySong.mp3');
    
// } 
new p5.SoundFile('https://www.dropbox.com/preview/mySong.mp3')
function setup() {
  createCanvas(720, 200);
  background(255, 0, 0);
}

function mousePressed() {
  if (song.isPlaying()) {
    // .isPlaying() returns a boolean
    song.stop();
    background(255, 0, 0);
  } else {
    song.play();
    background(0, 255, 0);
  }
}

Help in solving this problem would be greatly appreciated!
````

---

<div class="post-metadata">

**Author:** ![Kris1](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kris1/32/9385_2.png) [@Kris1](https://discourse.processing.org/u/Kris1)\
**Post date:** [May 27, 2020, 7:22pm UTC](https://discourse.processing.org/t/loading-large-sound-files-problem-with-loading-solved/21351/2 "2020-05-27T19:22:45Z")

</div>

The idex code just to make sure```  
type or paste code here

```auto
<script src="path/to/p5.sound.js"></script>
<html lang="en">
  <head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.10.2/p5.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.10.2/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:** ![Sven](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sven/32/8293_2.png) [@Sven](https://discourse.processing.org/u/Sven)\
**Post date:** [May 27, 2020, 8:56pm UTC](https://discourse.processing.org/t/loading-large-sound-files-problem-with-loading-solved/21351/3 "2020-05-27T20:56:13Z")

</div>

Hello @Kris1,

That Dropbox URL (`https://www.dropbox.com/preview/mySong.mp3`) looks suspicious to me. 🙂 URL:s for sharing contains some kind of user identifier usually. Looking like this:

`https://dl.dropboxusercontent.com/s/b0a7xhsu4o06wkx/Abba%20Mani%20Abba%20Mani.mp3`

---

<div class="post-metadata">

**Author:** ![Kris1](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kris1/32/9385_2.png) [@Kris1](https://discourse.processing.org/u/Kris1)\
**Post date:** [May 28, 2020, 6:12pm UTC](https://discourse.processing.org/t/loading-large-sound-files-problem-with-loading-solved/21351/4 "2020-05-28T18:12:26Z")

</div>

Ahh…Thank you, @Sven.  
I tried the share link so [https://www.dropbox.com/s/ei01e2vmt1f3pxi/mySong.mp3?dl=0](https://www.dropbox.com/s/ei01e2vmt1f3pxi/mySong.mp3?dl=0)

Unfortunately, it still fails.

index file as above new code `  
let song;

// function preload(){  
// song = loadSound(‘[https://www.dropbox.com/s/ei01e2vmt1f3pxi/mySong.mp3?dl=0](https://www.dropbox.com/s/ei01e2vmt1f3pxi/mySong.mp3?dl=0)’);

// }  
new p5.SoundFile(‘[https://www.dropbox.com/s/ei01e2vmt1f3pxi/mySong.mp3?dl=0](https://www.dropbox.com/s/ei01e2vmt1f3pxi/mySong.mp3?dl=0)’)  
function setup() {  
createCanvas(720, 200);  
background(255, 0, 0);  
}

function mousePressed() {  
if (song.isPlaying()) {  
// .isPlaying() returns a boolean  
song.stop();  
background(255, 0, 0);  
} else {  
song.play();  
background(0, 255, 0);  
}

}

 ![Screenshot 2020-05-28 at 19.11.09](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/4/40005bc5c496cb97d55e20fe14dffc1890b5dbef.png)

[link to sketch](https://editor.p5js.org/kris1hillquist/sketches/o8UOSS7Po)

`Still stuck I am afraid.

---

<div class="post-metadata">

**Author:** ![Sven](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/sven/32/8293_2.png) [@Sven](https://discourse.processing.org/u/Sven)\
**Post date:** [May 28, 2020, 6:30pm UTC](https://discourse.processing.org/t/loading-large-sound-files-problem-with-loading-solved/21351/5 "2020-05-28T18:30:14Z")

</div>

You’re one step closer, at least. 😊 That URL points to a web page, not an mp3 file. What you want is probably: `https://dl.dropboxusercontent.com/s/ei01e2vmt1f3pxi/mySong.mp3`.

---

<div class="post-metadata">

**Author:** ![slow\_izzm](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/slow_izzm/32/5637_2.png) [@slow\_izzm](https://discourse.processing.org/u/slow_izzm)\
**Post date:** [May 28, 2020, 8:37pm UTC](https://discourse.processing.org/t/loading-large-sound-files-problem-with-loading-solved/21351/6 "2020-05-28T20:37:32Z")

</div>

@Sven is correct …

```auto
let song,
  AudioIsLoaded = false,
  col = {
    play: null,
    stop: null
  };

song = new p5.SoundFile('https://dl.dropboxusercontent.com/s/ei01e2vmt1f3pxi/mySong.mp3', _ => {
  console.log(`${song.url.substring(song.url.lastIndexOf('/')+1)} is loaded`);
  AudioIsLoaded = true;
});

setup = _ => {
  createCanvas(720, 200);
  col = {
    play: color(0, 200, 0),
    stop: color(200, 0, 0)
  }

  background(col.stop);
}

mousePressed = _ => {
  (!song.isPlaying() && AudioIsLoaded) ? (song.play(), background(col.play)) : (song.stop(), background(col.stop));
}

```

---

<div class="post-metadata">

**Author:** ![Kris1](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kris1/32/9385_2.png) [@Kris1](https://discourse.processing.org/u/Kris1)\
**Post date:** [May 31, 2020, 12:24pm UTC](https://discourse.processing.org/t/loading-large-sound-files-problem-with-loading-solved/21351/7 "2020-05-31T12:24:33Z")

</div>

> [@slow\_izzm](#):
>
> ```auto
> let song,
> AudioIsLoaded = false,
> col = {
> play: null,
> stop: null
> };
> 
> song = new p5.SoundFile('https://dl.dropboxusercontent.com/s/ei01e2vmt1f3pxi/mySong.mp3', _ => {
> console.log(`${song.url.substring(song.url.lastIndexOf('/')+1)} is loaded`);
> AudioIsLoaded = true;
> });
> 
> setup = _ => {
> createCanvas(720, 200);
> col = {
> play: color(0, 200, 0),
> stop: color(200, 0, 0)
> }
> 
> background(col.stop);
> }
> 
> mousePressed = _ => {
> (!song.isPlaying() && AudioIsLoaded) ? (song.play(), background(col.play)) : (song.stop(), background(col.stop));
> }
> 
> ```

Wow!!! Thank you! It works! Now I will spend time to fully understand this code. I appreciate your help and work on this subject!

---

<div class="post-metadata">

**Author:** ![Kris1](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kris1/32/9385_2.png) [@Kris1](https://discourse.processing.org/u/Kris1)\
**Post date:** [May 31, 2020, 12:26pm UTC](https://discourse.processing.org/t/loading-large-sound-files-problem-with-loading-solved/21351/8 "2020-05-31T12:26:43Z")

</div>

Thank you so much to both @Sven and @slow_izzm 😃
