我正在尝试在 Java 应用程序中以编程方式更改 gplay 的音量级别。视频播放正常;我看到了 gplay 的菜单;我得到了第一个“正在播放”提示,我为“[v]Volume”输入了一个“v”,但我从未看到音量提示“设置音量”。我从 BufferedReader 获得了我期望的所有数据,但 BufferedWriter 似乎不起作用。当我从控制台运行 gplay 时,一切都按预期工作。有人能看出我做错了什么吗?
谢谢。
List<String> command = new ArrayList<String>();
command.add("gplay");
command.add("demoVideo.mp4");
ProcessBuilder builder = new ProcessBuilder(command);
builder.directory(new File("/home/ubuntu"));
builder.redirectErrorStream(true);
Process playVideoProcess = builder.start();
// get the input stream connected to the normal output of the subprocess
InputStream is = playVideoProcess.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
// get the output stream connected to the normal input of the subprocess
OutputStream os = playVideoProcess.getOutputStream();
OutputStreamWriter osw = new OutputStreamWriter(os);
BufferedWriter bw = new BufferedWriter(osw);
while (true)
{
line = br.readLine();
if (line != null)
{
if (debug) logger.log(Level.INFO, "--> " + line);
if (line.contains("[Playing ][Vol=01]"))
{
bw.write("v");
bw.newLine();
bw.flush();
}
else if (line.contains("Set volume"))
{
bw.write("10");
bw.newLine();
bw.flush();
}
else if (line.contains("[Playing ][Vol=10]"))
{
logger.log(Level.INFO, "* Done. CLOSING ALL STREAMS *");
bw.close();
osw.close();
os.close();
br.close();
isr.close();
is.close();
break;
}
}
}
答案1
谢谢,Serg - 这是飞思卡尔半导体公司的流媒体播放器。以下是 PDF 手册的链接: