[MPlayer-users] execute external commands during media playing

Phil Rhodes phil_rhodes at rocketmail.com
Thu Apr 10 13:43:35 CEST 2008

> thanks, this seems to be very interesting. Doing such things with
> javascript code under windows would be very useful for me; could you
> please show me a simple part of your code, so I can start editing some
> working javascript code?

Not easily - it wasn't very simple!

The problem is that slave mode is riddled with bugs and appears to be more 
or less unmaintained; also, you will almost invariably find yourself wanting 
to do things it can't do, such as changing the pan audio filter. I 
eventually ended up relaunching mplayer from scratch for every file, so I 
could at least have per-file changes to all the usual command line stuff. It 
also doesn't help that JScript's stdio reader is blocking, so you have to be 
very sure you have something to read when you try to read it, or your 
program will become trapped in a lock-o-doom from which there is no escape.

Basically it works like this:

- Build a command line
- Run it with WScript.Shell's Exec method, keeping a reference to the 
- Request a time position update
- Request any other info you want
- Read lines until you see the time position update
- Do whatever you need to do based on the information received.
- Repeat

It's slightly flaky in that you could theoretically request a time pos as 
"any other info" and you would then stop reading too early, but the simple 
solution is "don't do that". There were a lot of exceptions and special 
cases for things which didn't quite work as advertised - if you seek to a 
given position then read the time position, it won't be the position you 
seeked to, for some reason. Tread carefully.


More information about the MPlayer-users mailing list