You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constfs=require('fs');constffmpeg=require('fluent-ffmpeg');constSpeaker=require('speaker');letplaying=false;letffmpegProcess=null;functionstartPlaying(filePath){if(playing){console.log("Audio is already playing.");return;}console.log("Starting playback...");playing=true;ffmpegProcess=ffmpeg(filePath).audioCodec('pcm_s16le').audioFilters('volume=1').format('wav').pipe(newSpeaker(),{end: false});ffmpegProcess.on('end',()=>{console.log("Audio playback finished.");playing=false;});ffmpegProcess.on('error',(err)=>{console.log("Error occurred during playback: ",err);playing=false;});}functionstopPlaying(){if(!playing){console.log("No audio is playing.");return;}console.log("Stopping playback...");playing=false;if(ffmpegProcess){ffmpegProcess.kill('SIGSTOP');console.log("FFmpeg process killed.");}}constfilePath='intro.mp3';startPlaying(filePath);setTimeout(()=>{stopPlaying();},5000);
Expected results
This should stop the audio, and continue the program.
Observed results
This should stop the audio, but results in a crash, that crashes the full program.
TypeError: ffmpegProcess.kill is not a function
at stopPlaying (C:\Users*\audioplayertest\app.js:44:23)
at Timeout._onTimeout (C:\Users*\audioplayertest\app.js:54:5)
at listOnTimeout (node:internal/timers:581:17)
at process.processTimers (node:internal/timers:519:7)
Node.js v20.17.0
The text was updated successfully, but these errors were encountered:
Version information
Code to reproduce
Expected results
This should stop the audio, and continue the program.
Observed results
This should stop the audio, but results in a crash, that crashes the full program.
TypeError: ffmpegProcess.kill is not a function
at stopPlaying (C:\Users*\audioplayertest\app.js:44:23)
at Timeout._onTimeout (C:\Users*\audioplayertest\app.js:54:5)
at listOnTimeout (node:internal/timers:581:17)
at process.processTimers (node:internal/timers:519:7)
Node.js v20.17.0
The text was updated successfully, but these errors were encountered: