Python: Send command to mplayer under slave mode

前端 未结 2 1236
时光说笑
时光说笑 2021-01-14 06:56

I\'m trying to send command via pipe to mplayer when running it under slave mode like this:

import subprocess, time
# start mplayer
song = \'mysong.mp3\'
cmd         


        
2条回答
  •  太阳男子
    2021-01-14 07:22

    I'm now doing it this way and I start to get output:

     while True:
        cmd = '\nget_meta_artist\n'
        p.stdin.write(cmd)
        output = p.stdout.readline()
        print("output: {}".format(output.rstrip()))
        sys.stdout.flush()
    

    Although I still need to figure out a way to bypass the first flush of mplayer's own initialization stdout but I consider my problem solved.

    Thanks to glglgl for giving me useful hints.

提交回复
热议问题