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

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

问题描述

我需要在 Raspberry Pi (RASPBIAN JESSIE) 上运行 JavaFX 项目.该项目包括 WebView 和 MediaView/MediaPlayer 的使用.由于 Oracle 在 ARM 平台上不支持 JavaFX,我尝试了 Gluon (JavaFX Embedded SDK 8.60.8) 的 JavaFX 端口.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 中,可以从 这里 并安装了最新的 JDK for ARM,可用 这里.

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天全站免登陆