用于在Swing应用程序中嵌入电影的任何简单(和最新)Java框架? [英] Any simple (and up to date) Java frameworks for embedding movies within a Swing Application?
问题描述
我正在构建一个我希望在其中嵌入电影的小型Swing应用程序。重要的是,这个应用程序是一个WebStart应用程序 - 该库应该能够打包在我启动的jnlp中 - 不依赖于本机库。
I am building a small Swing application that I would like to embed a movie within. Importantly, this application is a WebStart application - and the library should be able to be packaged within the jnlp that I launch -i.e, not dependent on native libraries.
我是知道并尝试过JMF,但与其他框架相比,我认为格式兼容性相对较差。
I am aware of and have tried JMF but the format compatibility I believe to be relatively poor when compared to other frameworks out there.
有人可以提供一个简单的示例代码片段使用他们推荐的库实现?
Could someone please provide a sample code snippet of a simple implementation using their recommended library?
非常感谢提前。
推荐答案
JavaFX作为基于Java的媒体播放框架的解决方案的一些注意事项。
Some considerations for JavaFX as a solution as a Java based media playback framework.
- 从Jdk7u4开始,JavaFX与jdk共同捆绑适用于Mac和Windows
(XP,Vista,7,32和64位)。 - JavaFX可以嵌入到Swing应用程序中。
- JavaFX包含本机库,但任何Java Framework都需要本机库来做好视频。
- JavaFX SDK附带了一个全面的部署工具包和/或包括生成基于jnlp的部署的能力。
- JavaFX 2.1支持vp6编码flvs(旧格式)以及一些更现代和常用的编码格式,如mp4 / aac / mp3。
- JavaFX仅支持有限的媒体编解码器和容器格式,例如如果您的计算机上安装了编解码器,并且可以播放以该格式编码的文件,例如chrome,windows media player或flash,但不保证同一文件将在JavaFX中播放。
- 在XP或Linux上播放mp4需要用户手动安装必要的编解码器,但其他平台(osx,win7,vista)不需要手动安装mp4编解码器。
- 在Mac上使用JavaFX需要用户使用OpenJDK 7 for Mac,而不是Apple JDK。
- JavaFX对Mac上jnlp启动的应用程序的支持将在今年晚些时候推出(对于Linux来说,类似于Linux。
- 您可以将整个JavaFX平台与您的应用程序捆绑在一个jnlp中(尽管我还没有看到任何人这样做过)。
- jnlp部署的推荐方法是向jnlp添加最小JavaFX环境的规范,并让JavaFX部署工具包和webstart负责确保它存在并且安装正确地在用户的机器上运行。
- Swing和JavaFX之间的交互需要一些不便和小心线程,以及在Swing和JavaFX之间稍微不同的应用程序启动代码。有些人在论坛上抱怨过这种情况,大多数人似乎没有太多问题。
- 无论好坏(我相信更好),JavaFX可能是唯一的媒体和来自Oracle的客户端开发框架正在接收持续的主要开发和新功能。
- 最终(今年或下一年)JavaFX将包含在运行现代版本的所有主要消费者平台的所有新Java运行时中Java SE。
- 来自Oracle和第三方的JavaFX开发社区支持(我相信)很好。
- As of Jdk7u4, JavaFX is co-bundled with the jdk for Mac and Windows (XP, Vista, 7, 32 and 64 bit).
- JavaFX can be embedded in a Swing App.
- JavaFX includes native libraries, but any Java Framework is going to need native libraries to do video well.
- A comprehensive deployment toolkit is included with the JavaFX SDK and/or includes the ability to generate jnlp based deployments.
- JavaFX 2.1 supports vp6 encoded flvs (older format) as well as some more modern and oft-used encoding formats such as mp4/aac/mp3.
- JavaFX only supports limited media codecs and container formats, e.g. if you have a codec installed on your machine and can play a file encoded in that format in, for example chrome, windows media player, or flash that does not guarantee that the same file will play in JavaFX.
- Playback of mp4 on XP or Linux requires a user to manually install the necessary codec, but other platforms (osx, win7, vista) do not require manual mp4 codec install.
- Use of JavaFX on a mac requires the user to use OpenJDK 7 for Mac, not the Apple JDK.
- JavaFX support for jnlp launched apps on Macs won't be available until later this year (2012) and similarly for Linux.
- You could probably bundle the entire JavaFX platform with your app in a jnlp (though I haven't seen anybody do that yet).
- The recommended method for a jnlp deployment would be to add a specification of a minimum JavaFX environment to the jnlp and have the JavaFX deployment toolkit and webstart take care of ensuring that it was present and installed correctly on the user's machine.
- Interaction between Swing and JavaFX requires some inconvenience and care around threading and also a slightly different app launching code between Swing and JavaFX. Some people have complained about this on forums, most don't seem to have had too many issues.
- For better or for worse (I believe better), JavaFX is likely the only media and client development framework from Oracle which is receiving ongoing major development and new features.
- Eventually (this year or next) JavaFX will included in all new Java runtimes for all major consumer platforms which run modern versions of Java SE.
- Community support for development in JavaFX from Oracle and 3rd parties is (I believe) good.
<这是一个播放视频的JavaFX应用示例:
Here is a sample JavaFX app which plays a video:
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.media.*;
import javafx.stage.Stage;
public class VideoPlayerExample extends Application {
public static void main(String[] args) throws Exception { launch(args); }
@Override public void start(final Stage stage) throws Exception {
final MediaPlayer oracleVid = new MediaPlayer(
new Media("http://download.oracle.com/otndocs/products/javafx/oow2010-2.flv")
);
stage.setScene(new Scene(new Group(new MediaView(oracleVid)), 540, 208));
stage.show();
oracleVid.play();
}
}
这篇关于用于在Swing应用程序中嵌入电影的任何简单(和最新)Java框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!