[vlc-devel] Proper way to wait for VLC remote interface messages...
Peter Tap
ptrtap at yahoo.com
Wed Feb 29 19:55:53 CET 2012
Folks,
In my Java application, I connect to VLC remote interface via socket, send the request (such as play, pause, etc.) and wait for the response. The way I am waiting for the response is shown in the following code:
publicstaticStringReadAvailableTextFromSocket(BufferedReaderinput)throwsIOException{
if(input.ready()==false){
returnnull;
}
StringBuilderretVal =newStringBuilder();
while(input.ready()){
charch =(char)input.read();
retVal.append(ch);
}
returnretVal.toString();
}
However, this does not seem to be a reliable way to get the response. VLC and/or network may take time to return the response. As a result, the above routine may just return null string.
I am wondering if there is a better way to receive the data back from VLC.
While playing with various commands, I noticed that the last line of the response seem to be the message token + ":"
Sent: play
Received: play: returned 0 (no error)
Sent: add file
Received: add: returned 0 (no error)
One idea I had was to read the response until token + ":" is returned as the beginning of the line. Will this work? Does VLC always return this type of response to signal the end?
Thank you in advance for your help.
Regards,
Peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20120229/b78c12d1/attachment.html>
More information about the vlc-devel
mailing list