[MPlayer-users] current position
Jason Tackaberry
tack at sault.org
Thu Aug 11 17:49:58 CEST 2005
On Thu, 2005-08-11 at 15:02 +0000, Vinay Reddy wrote:
> 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. :)
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.)
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.
Have fun,
Jason.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 229 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-users/attachments/20050811/24080b1a/attachment.pgp>
More information about the MPlayer-users
mailing list