Skip to content

Instantly share code, notes, and snippets.

@RamonRomeroQro
Last active November 21, 2018 00:31
Show Gist options
  • Save RamonRomeroQro/9a9e90590a3268312b470f97a3748458 to your computer and use it in GitHub Desktop.
Save RamonRomeroQro/9a9e90590a3268312b470f97a3748458 to your computer and use it in GitHub Desktop.

Revisions

  1. RamonRomeroQro revised this gist Nov 21, 2018. 1 changed file with 10 additions and 3 deletions.
    13 changes: 10 additions & 3 deletions playsound.py
    Original file line number Diff line number Diff line change
    @@ -30,10 +30,17 @@ def playthread(filedir):
    def stop():
    p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE)
    out, err = p.communicate()
    out.decode('UTF-8')
    for line in out.splitlines():
    a=[]
    for i in out:
    a.append(chr(i))
    a.split('\n')
    a="".join(a)
    a=a.split('\n')

    for line in a:
    if 'omxplayer' in line:
    pid = int(line.split(None, 1)[0])
    line=line.split()
    pid = int(line[0])
    os.kill(pid, signal.SIGKILL)

    if __name__ == '__main__':
  2. RamonRomeroQro revised this gist Nov 21, 2018. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions playsound.py
    Original file line number Diff line number Diff line change
    @@ -21,14 +21,16 @@
    def playsound (filedir):
    subprocess.call(['omxplayer', filedir])

    def multithread(filedir):
    p = multiprocessing.Process(target=playsound, args=(filedir))
    def playthread(filedir):
    p = multiprocessing.Process(target=playsound, args=(filedir,))
    p.start()
    p.join()


    def stop():
    p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE)
    out, err = p.communicate()
    out.decode('UTF-8')
    for line in out.splitlines():
    if 'omxplayer' in line:
    pid = int(line.split(None, 1)[0])
  3. RamonRomeroQro revised this gist Nov 20, 2018. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions playsound.py
    Original file line number Diff line number Diff line change
    @@ -15,11 +15,17 @@
    import subprocess, signal, time


    # multiprocessing_simple.py
    import multiprocessing

    def playsound (filedir):
    #llamada a modulo omxplayer
    subprocess.call(['omxplayer', filedir])


    def multithread(filedir):
    p = multiprocessing.Process(target=playsound, args=(filedir))
    p.start()
    p.join()

    def stop():
    p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE)
    out, err = p.communicate()
  4. RamonRomeroQro revised this gist Nov 20, 2018. 1 changed file with 13 additions and 1 deletion.
    14 changes: 13 additions & 1 deletion playsound.py
    Original file line number Diff line number Diff line change
    @@ -12,13 +12,25 @@
    '''
    import subprocess, signal, time


    import subprocess

    def playsound (filedir):
    #llamada a modulo omxplayer
    subprocess.call(['omxplayer', filedir])

    def stop():
    p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE)
    out, err = p.communicate()
    for line in out.splitlines():
    if 'omxplayer' in line:
    pid = int(line.split(None, 1)[0])
    os.kill(pid, signal.SIGKILL)

    if __name__ == '__main__':
    #playsound (filedir)
    #time.sleep(5)
    #stop()


  5. RamonRomeroQro created this gist Nov 15, 2018.
    24 changes: 24 additions & 0 deletions playsound.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    '''
    @Krotolamo
    Reproducir sonido, recibe como parametro la ubicacion de archivo
    Deberia correr sin problemas porque el paquete ya vien instalado en la RBP,
    pero si no, estos son los comandos de instalacion
    $ sudo apt update
    $ sudo apt install omxplayer
    '''

    import subprocess

    def playsound (filedir):
    #llamada a modulo omxplayer
    subprocess.call(['omxplayer', filedir])

    if __name__ == '__main__':
    #playsound (filedir)