Skip to content

How do you load a Sound object in tinySound in visual studio code?

Here is the example provided by the library tinySound :

I read the example and wrote the basic piece of code to test its functions :

Music forest = TinySound.loadMusic("absolutepath/day.ogg");;

Upon execution I get :

Unable to find resource /absolutepath/day.ogg!

I work with visual studio code and was wondering why java couldn’t find the file, even though the path put in is absolute and the resource is in the workspace.

Here is the reduced project tree structure :

 |------/ (location of my test of tinySound)



After tinkering around a bit, I found an alternative to absolute paths for tinySound in vsc.

It goes as follows :

File aFilesound = new File("relativePath/file.wav");
Music fileMusic = TinySound.loadMusic(aFilesound);;

This way, the resource folder doesn’t need to be in the src folder for the music to work.