I was building another package called cliclock and I needed to play sound when the timer ends. So tried to play sound then I played sound but then I failed to stop it.
Then I spent a few days asking ChatGPT for solution and it gave this solution.
I just prompted it.
npm install playsoundwithvlcimport{playSound,stopSound}from"playsoundwithvlc";constfilePaths={vlcExePath: "C:\\Program Files\\VideoLAN\\VLC\\vlc.exe",audioPath: "C:\\Users\\Sooraj\\Desktop\\audio.mp3",};playSound(filePaths.vlcExePath,filePaths.audioPath);setTimeout(()=>{stopSound();},5000);import{spawn}from"child_process";letplayerProcess;// Function to play soundfunctionplaySound(vlcExePath,audioPath){// Spawn the VLC player processplayerProcess=spawn(vlcExePath,["--intf","dummy",audioPath]);}// Function to stop sound playbackfunctionstopSound(){if(playerProcess){// Send a SIGTERM signal to terminate the processplayerProcess.kill("SIGTERM");}}export{playSound,stopSound};