[MPlayer-users] current position

Vinay Reddy vinayvinay at gmail.com
Thu Aug 11 19:27:29 CEST 2005

> > don't use the -quiet option, do I start a separate thread in my
> > program which deals with mplayer output? What about the replies to
> > commands that I send to mplayer? Won't the status messages come in
> > between? Will I have to parse the output to find out if it's a status
> > message or a reply to my query?
> Don't use -quiet.  In fact, it might be better to use -v.  Yes, you will
> have to parse MPlayer's output.  No, you don't need to start another
> thread.  The very suggestion tells me you might be a Java programmer. :)

True, more or less.

> I'm not sure how you are interfacing with MPlayer, but the nature of
> your questions suggests you're not doing it the right way.  If you were,
> none of these things would be problems.
> You'll need to spawn MPlayer such that you can communicate with it
> bidirectionally.  High level languages tend to have this ability
> natively.  (In Python, for example, see the popen2 module.)  In C,
> you'll have to setup a pair of pipes and fork.  (Google for
> "bidirectional communication fork" or some such.)

I am programming in Python (my first program in this language) and I
am using the popen2 call. I communicate with mplayer using the two
pipes that are returned on calling popen2.
> Your application's main loop will select(2) on the file descriptor that
> maps to mplayer's stdout.  When there's output, handle it line by line
> and parse it for the lines you're interested in.  For status output,
> look for lines that start with "A:" or "V:" and from there you can
> easily parse the time.
> You should not require that mplayer outputs lines in an expected order.
> If you handle output as described above, you won't have to.

Thanks a lot. This sure clears everything (At this point it seems so ;-)).


More information about the MPlayer-users mailing list