w00t!

I got it to work.

It turns out that VLC *is* sending output to both stderr and stdout. From the oft-mentioned JavaWorld article, http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps_p.html, I added the StreamGobblers to play();

public void play() throws Exception {
String command = "\"C:\\Program Files\\VideoLAN\\VLC\\vlc.exe\" --extraintf=rc --rc-host=127.0.0.1:9066 --rc-quiet \"rtsp://192.168.0.66/\"; :sout=#duplicate{dst=display}";
Process child = Runtime.getRuntime().exec( command);
StreamGobbler err = new StreamGobbler( child.getErrorStream(), "err");
StreamGobbler out = new StreamGobble( child.getInputStream(), "out");
err.start();
out.start();
}


and now Launcher works both when called directly and when called from a JSP.

Now, as a result of this wild ride, it is not readily apparent:

1) where stderr gets piped to in DOS...when I ran the command directly at the DOS prompt, where was all of this output?
2) why it was running fine as >java Launcher but not when called from a JSP...the buffer of Runtime#exec() changes? It doesn't seem likely.


all of which would have given clues as to why and how everything was working and how it needed to be dealt with.

I guess the moral of the story is....ALWAYS gobble err and out even if you don't think they're being used.

Thanks to everyone for their help.

Cheers,
Steve

On Mar 25, 2005, at 1:48 PM, Steve Butcher (Steve-O) wrote:

I thought about this as well and originally dismissed the idea because:

1) when I run it at the command line (DOS prompt), there is no output.
2) when I run >java Launcher, it runs fine. It was not immediately apparent to me why the buffer might fill up when it was called via Tomcat v. "directly" (#1 notwithstanding).


However, I have since attempted a few things with the original code that lead me to believe that there is definitely *something* going. If I change the previous play() method to:

� � �public void play() throws Exception {
� � � � � String command = "\"C:\\Program Files\\VideoLAN\\VLC\\vlc.exe\" --extraintf=rc --rc-host=127.0.0.1:9066 --rc-quiet \"rtsp://192.168.0.66/\"; :sout=#duplicate{dst=display}";
� � � � � Process child = Runtime.getRuntime().exec( command);
int exit = child.waitFor();
� � �}


I can get the direct version (>java Launcher) to exhibit the same behavior (VLC launches but hangs with "End Program" dialog).

In any case, because you don't want your page to wait on a windowed application, you shouldn't call Process#waitFor() anyway which doesn't return until the windowed application is quit; however, it is an interesting clue.

Cheers,
Steve


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to