Skip to content

Instantly share code, notes, and snippets.

@RamonRomeroQro
Created December 12, 2018 07:39
Show Gist options
  • Save RamonRomeroQro/d5e597e331bdb56a35eb4e2e7fe89126 to your computer and use it in GitHub Desktop.
Save RamonRomeroQro/d5e597e331bdb56a35eb4e2e7fe89126 to your computer and use it in GitHub Desktop.
import time, multiprocessing, subprocess
from subprocess import PIPE, Popen
import os, signal
from subprocess import Popen, PIPE
def playsound(filedir):
global a
p = Popen(['omxplayer', filedir], stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
a.append(p)
def sound(s):
if s == '+': #or positive int
global a
print(a)
for x in (a):
x.stdin.write(b'+') # sends a space to the running process
x.stdin.flush()
else:
global a
print(a)
for x in (a):
x.stdin.write(b'-') # sends a space to the running process
x.stdin.flush()
def stopall():
global a
print(a)
for x in (a):
os.kill(x.pid, signal.SIGKILL)
a=[]
#x.stdin.write(b'+') # sends a space to the running process
#x.stdin.flush()
'''
'''
def main():
#hilo principal
global a
a=[]
for i in range(0,2):
p = playsound('/Users/ramonromero/Downloads/Computer_Music_All-Stars_-_Albatross_v2.mp3')
time.sleep(5)
sound()
stopall()
if __name__ == '__main__':
main()
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment