I am trying to use p5.js sound library in Node.js and the preload function simply throws an (understandable) error saying that it is not being used. How do I use the preload function in Node ?
import React, { Component } from 'react';
import p5 from "p5";
import 'p5/lib/addons/p5.dom';
import "p5/lib/addons/p5.sound";
import sound from "./audio/song.mp3";
import './App.css';
let song;
function preload() { // @preload is required by P5.js
p5.soundFormats('mp3', 'ogg');
song = p5.loadSound(sound);
}
class App extends Component {
render() {
return (
<div className="App">
<button>Click me</button>
</div>
);
}
}
export default App;