<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Subprocess :: CS2 course</title><link>https://robark.gitlab.io/subprocess/index.html</link><description>Chapter 3 Subprocess and Signal</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Wed, 02 Dec 2020 22:52:13 +0000</lastBuildDate><atom:link href="https://robark.gitlab.io/subprocess/index.xml" rel="self" type="application/rss+xml"/><item><title>Subprocess</title><link>https://robark.gitlab.io/subprocess/subprocess/index.html</link><pubDate>Wed, 02 Dec 2020 22:52:13 +0000</pubDate><guid>https://robark.gitlab.io/subprocess/subprocess/index.html</guid><description>Lesson 9: Subprocess and Signal An excellent website on subprocess is pymotw.com
In hindsight, I should have used the variable proc (for process) instead of pid (process id).
from fltk import * import subprocess as sp import signal def playb_cb(wid): global pid if pid==0: #no music playing already pid = sp.Popen(['vlc', '--intf', 'dummy', 'zapac.mp3']) # --intf dummy (interface dummy to disable vlc gui) def signal_cb(wid, s): global pid if pid!=0: # already playing pid.send_signal(s) if s==signal.SIGTERM: pid = 0 def close_win(wid): if pid!=0: pid.send_signal(signal.SIGTERM) wid.hide() pid=0 win=Fl_Window(300,300) win.begin() playb = Fl_Button(0,0,70,40,'@&gt;') stopb = Fl_Button(70,0,70,40,'@square') pauseb = Fl_Button(140,0,70,40,'@||') resumeb = Fl_Button(210,0,70,40,'@|&gt;') win.end() playb.callback(playb_cb) stopb.callback(signal_cb, signal.SIGTERM) pauseb.callback(signal_cb, signal.SIGSTOP) resumeb.callback(signal_cb,signal.SIGCONT) win.callback(close_win) win.show() Fl.run() Another option is to use the vlc python API. Install the vlc module with the following command:</description></item></channel></rss>