Передача названия песни в omxplayer на python

Я передаю название песни функции и не могу найти путь для omxplayer

def PlayMusic(song):
  #check if the process exists
  is_pid = subprocess.call("pidof omxplayer.bin > /dev/null", shell=True)
  if is_pid == 0:
    return musicplaying("Song already Playing")
  else:
    pathsong ='/home/pi/'+song
    os.system('omxplayer --no-keys -o local pathsong &')
    return musicplaying (song +" playing")

Как поместить 'pathsong' в командную строку omxplayer?

1 ответ

Это делает то, что я хочу

@webiopi.macro
def PlayMusic(song):
  #check if the process exists
  is_pid = subprocess.call("pidof omxplayer.bin > /dev/null", shell=True)
  if is_pid == 0:
    # Don't play song
    msg = 'Song already playing - please wait'
  else:
    path = '/home/pi/music'
    for infile in glob.glob(os.path.join(path, song)):
      a = subprocess.call( [ "omxplayer", "--no-keys", "-o", "local", infile, "&"] )
    msg = 'Now playing ' + song
  return (msg)
Другие вопросы по тегам