gpt4 book ai didi

JavaFX 示例代码不播放视频,仅显示媒体播放器

转载 作者:行者123 更新时间:2023-12-01 12:08:20 26 4
gpt4 key购买 nike

我在 Netbeans - Ubuntu 14.04 上创建了一个示例代码 - 视频在该示例之外从同一路径正常播放。该路径仅在我的计算机上。

package javafxapplication1;

import java.io.File;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.stage.Stage;

public class JavaFXApplication1 extends Application {

public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
String workingDir = System.getProperty("user.dir");
System.out.println("workingDir"+workingDir);
File f = new File(workingDir, "the_appartition.flv");


//try{

//Media m = new Media(f.toURI().toString());

Media m = new Media("http://192.168.1.251/test/videos/the_appartition.flv");
System.out.println("media "+m.getSource());
MediaPlayer mp = new MediaPlayer(m);
MediaView mv = new MediaView(mp);

StackPane root = new StackPane();
root.getChildren().add(mv);

primaryStage.setScene(new Scene(root, 960, 540));
primaryStage.setTitle("Video Player 1");
primaryStage.show();

mp.play();
/*}
catch(Throwable t)
{
t.printStackTrace();

}*/
}
}

它显示空白媒体播放器而没有任何错误/异常的原因是什么。

最佳答案

这个问题有一个固定的 JIRA

[Linux] JavaFX Media does not run on Ubuntu 14.04

在Java 8u40版本中已修复。如果您确实想运行它,您可能需要从 JDK™ 8u40 Early Access Releases 下载并安装早期可用版本的 JDK。

关于JavaFX 示例代码不播放视频,仅显示媒体播放器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27419148/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com