I'm having problems with the exec command. I have mplayer set up to download a stream to disk (thus allowing me to listen to a live broadcast on my ipod later). I was trying to wrap this functionality into a small
java program to do a few other things with it. The only way I know to run a unix program, mplayer, from java is with Runtime.exec().
So here is what I have:
try
{
Runtime rt;
rt = Runtime.getRuntime();
System.out.println("1");
Process p = rt.exec("mplayer -playlist ~/Desktop/new.txt -ao pcm -aofile ~/mystream.wav -vc dummy -vo null");
Process p = rt.exec(arg);
int val = p.waitFor();
BufferedReader br = new BufferedReader( new InputStreamReader( p.getInputStream() ) );
while ( (line = br.readLine()) != null )
{
System.out.println(line);
}
System.out.println("2:rtn Val: "+val);
}
catch (Exception e)
{
e.printStackTrace();
}
and the output is:
matt:~/development/java/StreamToMP3 matt$ java StreamToMP3
1
MPlayer dev-CVS-040614-08:32-3.3 (C) 2000-2004 MPlayer Team
AltiVec found
CPU: PowerPC
Reading config file /usr/local/etc/mplayer/mplayer.confReading config file /Users/matt/.mplayer/config
2: rtn Val: 1
As you can see, it starts to run the mplayer command. But, it doesn't finish. The file it tries to download is not complete, in fact it never even creates the file "mystream.wav". I would think that using the p.waitFor() would make this happen, but it doesn't seem to.
Any thoughts?
[ July 09, 2004: Message edited by: Matt Zollinhofer ]
[ July 09, 2004: Message edited by: Matt Zollinhofer ]