3
我試圖從python程序控制mplayer的音量。 MPlayer的程序會從一個bash腳本開始:從Python程序寫入FIFO
#!/bin/bash
mkfifo /home/administrator/files/mplayer-control.pipe
/usr/bin/mplayer -slave -input file=/home/administrator/files/mplayer-control.pipe /home/administrator/music/file.mp3
然後我用Python寫的一個GUI,應該是能夠控制正在播放的mplayer的實例的量。我已經嘗試了以下內容:
os.system('echo "set_property volume $musicvol" > /home/administrator/files/mplayer-control.pipe')
如果我將$ musicvol替換爲數字值,但這很不幸沒用。我需要能夠傳遞變量。
我也將能夠從Python應用程序調用bash腳本來解決這個問題,但我不能得到那個工作之一:
subprocess.call("/home/administrator/files/setvolume.sh", executable="bash", shell=True)
非常感謝Mark !.這解決了它(使用你推薦的選擇)。 – Julio 2011-01-19 13:21:41