在Raspberry Pi上使用JavaFX播放视频 [英] Play a video using JavaFX on Raspberry Pi

查看:211
本文介绍了在Raspberry Pi上使用JavaFX播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Raspberry Pi(RASPBIAN JESSIE)上运行JavaFX项目。该项目包括WebView和MediaView / MediaPlayer的使用。由于Oracle在ARM平台上不支持JavaFX,我尝试使用Gluon的JavaFX端口(JavaFX Embedded SDK 8.60.8)。 WebView几乎完美地工作。但是,当我想使用MediaPlayer / MediaView播放视频时,我得到例外:

I need to run a JavaFX project on Raspberry Pi (RASPBIAN JESSIE). The project includes usage of WebView and MediaView/MediaPlayer. Since Oracle does not support JavaFX on ARM platforms, I tried JavaFX port by Gluon (JavaFX Embedded SDK 8.60.8). WebView works almost perfectly. However, when I want to play a video using MediaPlayer/MediaView, I get the exception:

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$launchApplication$156(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$launchApplication1$163(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$176(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$174(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$175(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应用程序?

Any ideas how to successfully run a JavaFX application with WebView and MediaView/MediaPlayer on Raspberry Pi?

推荐答案

WebView和Media从未成为JavaFX ARM发行版的一部分,但Gluon最近将其添加到嵌入式SDK中,可以从这里并安装了最近的ARM JDK,可用这里

WebView and Media were never part of the JavaFX ARM distribution, but Gluon recently added it to the embedded SDK that can be downloaded from here and installed with a recent JDK for ARM, available here.

媒体需要一些额外的步骤,因为它依赖于通常未在常规Jessie上完全安装的本机驱动程序分发。

Media requires a few extra steps as it depends in the native drivers that usually are not fully installed on a regular Jessie distribution.

首先安装这些驱动程序:

First install these drivers:

sudo apt-get install gstreamer0.10-plugins-good
sudo apt-get install gstreamer0.10-plugins-bad 

现在编辑 /etc/apt/sources.list 并在最后添加:

Now edit /etc/apt/sources.list and add at the end:

deb http://ftp.uk.debian.org/debian/ wheezy main
deb-src http://ftp.uk.debian.org/debian/ wheezy main

保存文件(Ctrl + O,Ctrl + X)。

Save the file (Ctrl+O, Ctrl+X).

最后更新并安装驱动程序:

Finally update and install the drivers:

sudo apt-get update
sudo apt-get install gstreamer0.10-ffmpeg
sudo apt-get install gstreamer0.10-alsa

现在你可以试试再次运行你的JavaFX应用程序。

Now you can try to run again your JavaFX application.

如果你再次找到相同的异常( MediaException:UNKNOWN ),检查是否它显示以下消息: GstPipelineFactory 中的错误,请注意缺少的驱动程序,并尝试安装它。

If you find again the same exception (MediaException: UNKNOWN), check if it shows this message: Error in GstPipelineFactory, notice the driver that is missing, and try to install it.

这篇关于在Raspberry Pi上使用JavaFX播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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