Here is what I currently am attempting:
final AudioClip note0 = new AudioClip(getClass().getResource("/Downloads/notes/A3.aiff").toString());
key0.setOnMouseClicked(new EventHandler<MouseEvent>()
{
@Override
public void handle(MouseEvent me)
{
note0.play();
}
});
I want to tie a key (Rectangle object) to a note (.aiff audio file). However, I am not sure how to reference the file path in .getResource(). Could anyone offer me advice on how to proceed? Thank you!
getRessource works for resources, which are files that are part of your program. For external files, you'll probably need a file URL:
The path to your home directory may be missing in the path.
Alternatively, copy A3.aiff to the resources (or source) root directory of your code, then access it as a resource: