somafm
somafm copied to clipboard
playback continues after quitting
This has been annoying me for months now. I tried to fork and fix it but failed due to time constraints and not being that interested in JavaScript.
mpv
is still running after stopping somafm
(via ^C
).
Steps to reproduce
$ somafm play defcon
Playing SomaFM DEF CON Radio
Pressing Ctrl+c
at this point causes the program to output
undefined undefined
and the music keeps playing
$ ps a | grep mpv | grep -v grep
7421 pts/8 Sl 0:01 mpv -quiet http://ice1.somafm.com/defcon-256-mp3
Workaround
$ killall mpv
This isn't perfect when you have multiple instances of mpv
running (eg. some clips paused waiting to be finished).
Version info
$ somafm --version
2.1.2
$ mpv --version
mpv 0.23.0 (C) 2000-2016 mpv/MPlayer/mplayer2 projects
built on UNKNOWN
ffmpeg library versions:
libavutil 55.34.101
libavcodec 57.64.101
libavformat 57.56.101
libswscale 4.2.100
libavfilter 6.65.100
libswresample 2.3.100
ffmpeg version: 3.2.5-1
Hi @czesiekhaker,
Thanks for your report!
I can't reproduce this on my machine. Pressing ctrl+c or q or esc kills the MPlayer or mpv process as expected.
What OS and Node.js version are you using?
You could try the following steps and check if they change anything:
- Run
$ mpv http://ice1.somafm.com/defcon-256-mp3
directly and press ctrl+c to see if the process exits. - Install the latest version of Node.js.
- Install the latest version of mpv.
- Install MPlayer. It will be used by default when available.
- Use a different kill signal by adding a parameter to the
kill()
function call. The default is'SIGTERM'
, maybe'SIGINT'
or'SIGKILL'
work better here (althoughSIGKILL
is less friendly).
(I'll fix the undefined
output in the next release.)
Switched to execa
and force-killing after a timeout. (17919760b0258300c18999d9c64d6fd6aa101a5c)
This should solve the issue.