I tried to install several modules to play audio in node.js. I've tried various modules, but none of them worked.
Among them, I would like to ask you whether the most popular module works.
The link to the module is here. https://npm.io/package/sound-play
Here's the code that failed.
const express = require("express"),nunjucks = require("nunjucks"),fs = require("fs").promises;
const app = express();
const path = require("path");
const sound = require("sound-play");
....
app.get("/play", (req, res) => {
fs.readdir("./musicBox")
.then((filelist) => {
const filePath = path.join(`./musicBox/`, filelist[count]);
console.log(filePath);
sound.play(filePath);
})
.catch((err) => {
throw err;
});
res.redirect("/");
});
and index.html is
...
<form action="/play" method="get">
<input type="submit" value="재생"/>
</form>
...
There's no error message when you click it.