Play audio inside a T3 app
Hi all!
I would like to play a success sounds when the user completes a task. What I have been trying is this:
import useSound from "use-sound";
import success from "../../public/sounds/fanfare.mp3";
...
const [play] = useSound(success);
Once my conditions for success are met I want to use:
{play}
For my .mp3 files to be detected I have added an audio.d.ts file in my /types folder:
declare module "*.mp3";
But when my I try this I get this error:
./public/sounds/fanfare.mp3
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
I do believe my files (have tried a couple of them) are ok since I can import and play them with an <audio /> tag.
Does anyone have any advice for what I would need to do to play my files with either use-sounds or any other package?
webpack
Concepts | webpack
0 Replies