Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 11-30-2009, 11:20 PM   #1
LQ Newbie
Registered: Nov 2009
Posts: 1

Rep: Reputation: 0
MPlayer slave mode question: how to know when song is done playing?


I have an application that sends and receives commands from mplayer in slave mode (#mplayer -slave -quiet -idle). I need to know when mplayer is done playing all of the files in its playlist (or with the file it was just playing). Currently, mplayer doesn't seem to respond to any commands once it is done playing except 'quit' and 'load <song> <1 or 0>'.

Currently I read the output that mplayer sends out, and call BufferedReader.readline() each time and inspect if the output matches a query I've sent earlier (such as get_property filename). Mplayer will send back ANS_filename=<filename>. But if there is no song currently playing, Mplayer doesn't respond at all, and so readline() blocks indefinitely. A simple solution would be to call BufferedReader.ready() before readline() and see if there is anything on the input buffer, but this is not the 'good' solution because it pretty much depends on the timing of the ready() call. I.e., I could call ready() and it could return false even if mplayer is still playing but hasn't responded quickly enough.

I need to know if mplayer is done playing the song(s) I gave it, that way my application can go query a server for more songs to give mplayer. The timing is important for picking the songs that the server sends back, so I don't want to ask the server for songs until I definitely need to.

Also, I would prefer to keep the current mplayer process alive the whole time (thus the -idle option). I understand mplayer will exit when it's done playing, and thus I can just check if its still alive, but I would prefer not to do that (I'd have to keep track of volume and other properties and such on my application layer so that the state stays the same when I start up a new mplayer client).

Thanks in advance,


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to stop mplayer from resuming play when any key is pressed (slave mode)? lumix Linux - Software 2 07-19-2012 11:34 AM
MP3 song not playing bhavin.h Linux - Newbie 5 12-04-2008 02:18 AM
No song tiltles listed when playing a CD-R JosephS Linux - Software 0 09-18-2007 08:37 AM
rhythmbox segfaults when playing song noeffred Linux - Hardware 0 04-08-2005 10:40 AM
Playing Quake3 in windowed mode... x windows question Thaidog Linux - Newbie 3 05-25-2004 08:42 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:20 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration