在 Raspberry Pi 上使用 JavaFX 播放视频
Play a video using JavaFX on Raspberry Pi
我需要在 Raspberry Pi (RASPBIAN JESSIE) 上 运行 一个 JavaFX 项目。该项目包括 WebView 和 MediaView/MediaPlayer 的使用。由于 Oracle 不支持 ARM 平台上的 JavaFX,我尝试了 Gluon 的 JavaFX 端口(JavaFX Embedded SDK 8.60.8)。 WebView 几乎完美地工作。但是,当我想使用 MediaPlayer/MediaView 播放视频时,出现异常:
Error in GstPipelineFactory: can't find element for factory named qtdemux
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication6(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: MediaException: UNKNOWN : com.sun.media.jfxmedia.MediaException: Could not create player! : com.sun.media.jfxmedia.MediaException: Could not create player!
at javafx.scene.media.MediaException.exceptionToMediaException(MediaException.java:146)
at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:511)
at javafx.scene.media.MediaPlayer.<init>(MediaPlayer.java:414)
at zirro.App.start(App.java:21)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication13(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait6(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null4(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater5(PlatformImpl.java:294)
at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
... 1 more
Caused by: com.sun.media.jfxmedia.MediaException: Could not create player!
at com.sun.media.jfxmediaimpl.NativeMediaManager.getPlayer(NativeMediaManager.java:224)
at com.sun.media.jfxmedia.MediaManager.getPlayer(MediaManager.java:104)
at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:467)
... 10 more
关于如何在 Raspberry Pi 上成功 运行 具有 WebView 和 MediaView/MediaPlayer 的 JavaFX 应用程序的任何想法?
WebView 和 Media 从来都不是 JavaFX ARM 发行版的一部分,但 Gluon 最近将其添加到可从 here and installed with a recent JDK for ARM, available here.
下载的嵌入式 SDK 中
Media 需要一些额外的步骤,因为它取决于通常未完全安装在常规 Jessie 发行版中的本机驱动程序。
首先安装这些驱动程序:
sudo apt-get install gstreamer0.10-plugins-good
sudo apt-get install gstreamer0.10-plugins-bad
现在编辑/etc/apt/sources.list
并在末尾添加:
deb http://ftp.uk.debian.org/debian/ wheezy main
deb-src http://ftp.uk.debian.org/debian/ wheezy main
保存文件(Ctrl+O、Ctrl+X)。
最后更新并安装驱动程序:
sudo apt-get update
sudo apt-get install gstreamer0.10-ffmpeg
sudo apt-get install gstreamer0.10-alsa
现在您可以再次尝试 运行 您的 JavaFX 应用程序。
如果您再次发现相同的异常(MediaException: UNKNOWN
),请检查它是否显示此消息:Error in GstPipelineFactory
,注意缺少的驱动程序,并尝试安装它。
我想更新来自 José Pereda
的正确答案。
gstreamer
的存储库不是最新的。这就是我让它工作的方式。
更新/etc/apt/sources.list
deb [trusted=yes] http://archive.debian.org/debian wheezy main
deb-src [trusted=yes] http://archive.debian.org/debian/ wheezy main
然后安装依赖项。
sudo apt-get install libtag1-vanilla
sudo apt-get install libtag1-rusxmms
sudo apt-get install libtag1c2a
sudo apt-get install gstreamer0.10-plugins-good
sudo apt-get install gstreamer0.10-plugins-bad
sudo apt-get install gstreamer0.10-ffmpeg
sudo apt-get install gstreamer0.10-alsa
我需要在 Raspberry Pi (RASPBIAN JESSIE) 上 运行 一个 JavaFX 项目。该项目包括 WebView 和 MediaView/MediaPlayer 的使用。由于 Oracle 不支持 ARM 平台上的 JavaFX,我尝试了 Gluon 的 JavaFX 端口(JavaFX Embedded SDK 8.60.8)。 WebView 几乎完美地工作。但是,当我想使用 MediaPlayer/MediaView 播放视频时,出现异常:
Error in GstPipelineFactory: can't find element for factory named qtdemux
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:389)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication6(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: MediaException: UNKNOWN : com.sun.media.jfxmedia.MediaException: Could not create player! : com.sun.media.jfxmedia.MediaException: Could not create player!
at javafx.scene.media.MediaException.exceptionToMediaException(MediaException.java:146)
at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:511)
at javafx.scene.media.MediaPlayer.<init>(MediaPlayer.java:414)
at zirro.App.start(App.java:21)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication13(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait6(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null4(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater5(PlatformImpl.java:294)
at com.sun.glass.ui.monocle.RunnableProcessor.runLoop(RunnableProcessor.java:92)
at com.sun.glass.ui.monocle.RunnableProcessor.run(RunnableProcessor.java:51)
... 1 more
Caused by: com.sun.media.jfxmedia.MediaException: Could not create player!
at com.sun.media.jfxmediaimpl.NativeMediaManager.getPlayer(NativeMediaManager.java:224)
at com.sun.media.jfxmedia.MediaManager.getPlayer(MediaManager.java:104)
at javafx.scene.media.MediaPlayer.init(MediaPlayer.java:467)
... 10 more
关于如何在 Raspberry Pi 上成功 运行 具有 WebView 和 MediaView/MediaPlayer 的 JavaFX 应用程序的任何想法?
WebView 和 Media 从来都不是 JavaFX ARM 发行版的一部分,但 Gluon 最近将其添加到可从 here and installed with a recent JDK for ARM, available here.
下载的嵌入式 SDK 中Media 需要一些额外的步骤,因为它取决于通常未完全安装在常规 Jessie 发行版中的本机驱动程序。
首先安装这些驱动程序:
sudo apt-get install gstreamer0.10-plugins-good
sudo apt-get install gstreamer0.10-plugins-bad
现在编辑/etc/apt/sources.list
并在末尾添加:
deb http://ftp.uk.debian.org/debian/ wheezy main
deb-src http://ftp.uk.debian.org/debian/ wheezy main
保存文件(Ctrl+O、Ctrl+X)。
最后更新并安装驱动程序:
sudo apt-get update
sudo apt-get install gstreamer0.10-ffmpeg
sudo apt-get install gstreamer0.10-alsa
现在您可以再次尝试 运行 您的 JavaFX 应用程序。
如果您再次发现相同的异常(MediaException: UNKNOWN
),请检查它是否显示此消息:Error in GstPipelineFactory
,注意缺少的驱动程序,并尝试安装它。
我想更新来自 José Pereda
的正确答案。
gstreamer
的存储库不是最新的。这就是我让它工作的方式。
更新/etc/apt/sources.list
deb [trusted=yes] http://archive.debian.org/debian wheezy main
deb-src [trusted=yes] http://archive.debian.org/debian/ wheezy main
然后安装依赖项。
sudo apt-get install libtag1-vanilla
sudo apt-get install libtag1-rusxmms
sudo apt-get install libtag1c2a
sudo apt-get install gstreamer0.10-plugins-good
sudo apt-get install gstreamer0.10-plugins-bad
sudo apt-get install gstreamer0.10-ffmpeg
sudo apt-get install gstreamer0.10-alsa