[MPlayer-users] Slave mode - detecting end of file.
tevans.uk at googlemail.com
Mon Feb 28 22:05:44 CET 2011
On Mon, Feb 28, 2011 at 9:28 AM, Edd Barrett <vext01 at gmail.com> wrote:
> Hi there,
> I have been googling around for a while trying to figure out how I can
> detect when a song has finished playing on an instance of mplayer in
> (idle) slave mode. My application is unable to queue multiple songs in
> an mplayer slave because the playlist ordering is subject to change,
> so it is vital I find a way to know when a song has ended.
> I found an almost identical question here:
> If you follow up the thread you eventually find reference to a patch
> which did more or less this, but was abandoned.
> So my question is, has anything changed since then? If not, can i
> suggest that an idle mplayer slave should still repond to commands
> even if nothing is playing?
> So perhaps "get_file_name" might respond "FILE_NAME: <null>", which
> can then be picked up by the master application. As it stands, mplayer
> says nothing if nothing is playing, so read()s on a named pipe will
> just block; this encourages people to write time sensitive code, which
> I am dismissing on the grounds that it is too difficult to avoid race
> Another idea: Perhaps, you can pass a PID to an mplayer slave so that
> mplayer can send a SIGUSR1 to the master, indicating the end of a
> For now my application will just fork a new mplayer for each track, as
> i can easily detect the end of a track using a wait() or waitpid().
> Any thoughts?
> Best Regards
> Edd Barrett
You don't need a patch to do this:
When mplayer reaches the end of the file, it will emit a message like so:
EOF code: 0
More information about the MPlayer-users