Why isn't sound working in webview for p5.js

The program Im making uses the p5 library. The sound works in the repl site but doesn’t work in the actual website.

Heres the code:

let timeElapsed = 0;
let c1,c2;
let noiseScale=0.0045;
var moon
let w, h, x, y, lag;
let trx, trry, tlx, tly, brx, bry, blx, bly;

var background;

function preload()
{
  moon = loadImage("moon.svg");
  background = loadSound("Lofi.mp3");
}
function setup()
{
	createCanvas(windowWidth,windowHeight)
	frameRate(100);
   w = width/2;
   h = height/2;
   x = width/2;
   y = height/2;
   lag = 10;
  noCursor();
  background.play();
}

function draw()
{

  timeElapsed++;

  //237, 187, 85(c1)
  //207, 143, 203(c2)
  
 c1 = color(138, 65, 121);
  c2 = color(227, 127, 144);
  
  for(let y=0; y<height; y++){
    n = map(y,0,height,0,1);
    let newc = lerpColor(c1,c2,n);
    stroke(newc);
    line(0,y,width, y);
  }


    image(moon,width-170,60,250,200);
  
for (let x=0; x < width; x++) {
 let noiseVal = noise((mouseX+x)*noiseScale, 
  10*noiseScale);
    stroke(245);
    line(x, 300+noiseVal*650, x, height);
    }

  noStroke();
  fill(255);
  rect (0, height-65, width, 65);
    x += (mouseX-x)/lag
   y += (mouseY-y)/lag
   circle(x, y, 30);
}

function windowResized() {
  resizeCanvas(windowWidth, windowHeight);
}

Hello @DylnPickl! Please edit your post’s code to be formatted like this:

```javascript
Your code here
```

So that it is easier for staff and members of the community to help you with your issue!

Also see this guide on how to share your code:

1 Like

Sorry. How do I edit the post

There should be a bar like this at the bottom of your post, click the pencil icon.
image

1 Like

nope, i just made a new one
Screenshot 2023-04-06 8.05.06 PM

:wave: Welcome to the community @DylnPickl!

Could you provide a link to the repl this code is in?

https://replit.com/@DylnPickl/School-Game-Jam?v=1

1 Like

Ah, so in the console, you’ll see P5 warning you you’ve made a variable background but a function with that name already exists as a post of the P5 library. I forked your repl and renamed the background variable to _background and that served to fix the issue, try rehabbing the variable and let me know if that works.

Thanks for the feedback! I tried it out and the song plays on the repl site but it still doesn’t play when in the webview tab.

1 Like

It seems to be playing on my side, did you accidentally muted Replit or something like that?