title: Get VLC remote control interface player state
body: <p>I am currently on a java project that uses a vlc socket remote control interface to play audiovisual content (e.g. <code>vlc -I rc --rc-host=localhost:[portnumber]</code>). The interface leads to some particular cases that seem complex to deal with:</p>
  
  <ul>
  <li><p>According to the vlc remote control help, the pause command is a toggle function so you
    have to keep trace of the current state of the player.</p></li>
  <li><p>The <code>add</code> command will start the video only if the current video isn't paused.</p></li>
  <li><p>The <code>is_playing</code> command always outputs 1, whenever it is paused or not and the
    <code>status</code> command doesn't say if it is paused or not.</p></li>
  </ul>
  
  <p>A constraint of the client is that videos need to be paused on the last frame. Fortunately, there is a parameter to deal with it : <code>--play-and-pause</code>.</p>
  
  <p>The problem is as following. If vlc gets to the last frame and pause the video by itself, how can I know about it ? For now, I use <code>get_time</code> in hope of simply considering the video paused if the countdown is equal to 0. However, it occurs that vlc pauses the video itself at 0:01, forcing me to also consier 0:01 as a finishing value. This results in a glitch when the user starts another video while there really is one second remaining before the last frame, since the 0:01 check is considering it as paused while it's not. Here's a summary of what happens:</p>
  
  <ul>
  <li><p>0:20 (not paused) + play button :
     send("add [filepath]");</p>
  
  <p><strong>Fine</strong></p></li>
  <li><p>0:00 (paused) + play button :
     send("pause");
     send("add [filepath]");</p>
  
  <p><strong>Fine</strong></p></li>
  <li><p>0:01 (paused) + play button :
     send("pause");
     send("add [filepath]");</p>
  
  <p><strong>Fine</strong></p></li>
  <li><p>0:01 (not paused) + play button :
     send("pause");
     send("add [filepath]");</p>
  
  <p><strong>Unexpected behavior: it won't play, because it is paused and we don't know about it</strong></p></li>
  </ul>
  
  <p>Is there a safe approach to deal with the player state so there is no undefined behavior? I noticed that the remote control console sometime outputs something when vlc pauses by itself. However, it seems unsafe since it may output some events that are fired before of after this event.</p>
  
  <p>Thank you.</p>