I am new here and new to the whole Python coding and my programming knowledge is low. I am designing a code that receives an IM on GTalk and based on the received messages a subprocess (mp4 or mp3 file on OMXPlayer) will run. at the moment i can run the subprocess but I can't pause/stop the mp3/mp4 files (subprocess). Any suggestion?
def message_handler(connect_object, message_node):
R = (message_node.getBody())
if R == "video" :
movie_path = '/home/pi/Desktop/media/video.mp4'
p = subprocess.Popen(['omxplayer',movie_path])
elif R == "music" :
movie_path = '/home/pi/Desktop/media/music.mp3'
p = subprocess.Popen(['omxplayer',movie_path])
elif R == "pause":
p.kill() # it gives me erroe "p is not defined"
os.kill(p.pid, signal.SIGSTOP) # doesn't do nothing
else:
pass