如何通过java控制VLC [英] how to control VLC by java

查看:227
本文介绍了如何通过java控制VLC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 java 中运行一个名为 VLC 的程序,并在运行时控制它,例如,如果用户点击❚❚ ►►按钮,我做了一个特定的合适动作。

I want to run a program called VLC in java and control it while running, for example if user clicked on ❚❚ or ►► button, I do a specific suitable action.

我跑 VLC 由此代码:

try
{
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec(VLCProgramAddFile + " udp://@:" + listeningPort);

    OutputStream out = p.getOutputStream();
    InputStream in = p.getInputStream();

    p.waitFor();
    System.out.println("End of VLC");
}
catch (Exception e)
{
    System.out.println("error in running VLC");
}

我听说过Java绑定,但我不知道它是怎么回事为这项工作工作。

I have heard about Java bindings, but I don't know how does it work for this job.

推荐答案

您可能正在寻找VLCJ,这是VLC的java包装器。它允许您将VLC媒体播放器嵌入到Java应用程序中,从而添加所有个人控件。

You are probably looking for VLCJ, this is a java wrapper for VLC. It allows you to embed VLC media player in a java application, and thus add all your personal controls.

(请注意,对于用户应用程序,这很好,但是VLCJ库不完美,你可以弹出几个问题
。)

(Do note that for user applications this is fine, but the VLCJ library isn't perfect, you can have several problems pop up.)

编辑:
对于我的项目,我看到了内存泄漏和长时间运行程序的问题(多个小时的多个实例)。特别是多个实例不能与某些编译选项(默认情况下处于启用状态)结合使用。

For my project I've seen memory leaks and issues with long running programs (multiple instances for several hours). Especially the multiple instances doesn't work in combination with some compile options (which are on by default).

这篇关于如何通过java控制VLC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆