2016-09-19 1 views
0

ich auf eine Funktion, einen Song-Namen bin vorbei und verwalten kann nicht den Weg für omxplayerSongnamen Passing in 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") 

zu konstruieren Wie kann ich ‚pathsong‘ in die omxplayer Befehlszeile setzen ?

Antwort

0

Das tut, was

Ich will
@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) 
Verwandte Themen