Playing a mp3 file

im making a game for school, were using html css and js but only coding in the file. i want to play a music mp3 file as background music so i went into a seperate repl to test the code for the music. i looked up help online and asked my teacher to try to get it to work but we have gotten absolutely nothing to work and idk what im doing wrong. here is my code:

import ddf.minim.*;
Minim minim;
AudioPlayer music;

void setup(){
minim = new Minim(this);
music = minim.loadFile(“virtualinsanity.mp3”);;

ive also tried this:

import processing.sound.*;
SoundFile music;

void setup(){
music = new SoundFile(this, “virtualinsanity.mp3”);;

ive tried converting the file to wav and aiff and triple checked if im spelling the file name right but i keep on getting a null error.

Hi @AramAsdourian

Could you use <AUDIO> HTML tags instead? That might work.

I’ve not tried the above code yet but think that the issue would be related to import ddf.minim

If you could share a link to the Repl it would be useful for others in the community.

1 Like

here is he link to my code:

i have not tried anything with html yet because i would like to try to keep everything in, unless if there is a way to have the audio tag in html react to a variable change in which is what i was going to have happen inside eventually.

Hi @AramAsdourian, there is a difference between JavaScript and Java. You can’t run Java inside an HTML, CSS, JS Repl. Instead, you should create a new Java Repl.