title: Python Subprocess stdout PIPE for mplayer processes
body: <p>I have written the following code as a frontend for mplayer using tkinter. However, I'm stuck trying to use commands like 'get_time_pos' from mplayer because the answer is very sporadically written into the PIPE. By this I mean that sometimes, it doesn't write it at all and isn't read until the program is closed and sometimes it does. But every time, the video gets paused even though the toggle for pause is set to play (since it was already paused) due to passing in the other command (get time pos).</p>
  
  <p>I'm at a loss, honestly and don't know how to fix this or even how to adequately describe the issue...</p>
  
  <p>FOLLOWUP: Im modifying the post by posting only the relevant code parts</p>
  
  <pre><code>from Tkinter import *
  from ttk import Frame
  from tkFileDialog import askopenfilename, askopenfile
  from tkMessageBox import showerror, showinfo
  from subprocess import *
  from threading import Thread
  from Queue import Queue, Empty, LifoQueue
  import os, sys
  import socket
  import select
  
  def command_player(self, comd):
      if self.mplayer_isrunning():
          try:
              self.player_process.stdin.write("%s\r\n"%comd)
              self.player_process.stdin.flush()
          except :
              showerror("Error","Error passing command to mplayer\n%s"%sys.exc_info()[1])
  
  self.player_process = Popen(["mplayer","-fs","-slave","-quiet","-wid",str(winid),self.filenm],stdin=PIPE, stdout=PIPE)
  
  #TRYING TO GET VIDEO POSITION IN TERMS OF % AND THEN PAUSE
  self.command_player("get_percent_pos")
  output = self.player_process.stdout.readline()
  self.command_player("pause")
  </code></pre>
  
  <p>The above does read the percent position but then it always keeps the video paused no matter what. If I keep only the pause command, the pause works as intended (it toggles b/w play and pause)</p>
  
  <p>Also, the select() portion was me trying out a different way but it doesn't work on windows since it's not a socket.
  Any more help fixing the subprocess input/output issue will be appreciated.</p>