mplayer - How can I detect EOF in Python
<p>I have a playlist that changes during play, Mplayer doesn't reload the playlist at the end of the first track so what I need to do is capture the EOF, then reload mplayer to carry on playing. How can I detect EOF using mplayer and popen? Or is there an easier way that I'm missing? I've checked the suggested 'duplicate' question and I don't believe it gives me the answer as this is capturing the end of a track/playlist via popen. </p>

<pre><code>def play_music():
  global myplaylist
  global playflag
  if not playflag:
    mycommand = ["mplayer -really-quiet -slave -volume 1 -playlist /home/pi/scripts/playlist.txt"]
    p = subprocess.Popen(mycommand, stdin=PIPE, stdout=PIPE, stderr=PIPE, shell=True)
   playflag = True
   else:
     pass
</code></pre>