媒体播放有问题,我用Java开发

时间:2015-09-11 11:45:43

标签: java media-player

我在Java IDE Eclipse中开发并运行了此代码。这是我为Main类开发的代码:

package application;

import com.sun.prism.paint.Color;



import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;


public class Main extends Application {
@Override
public void start(Stage primaryStage) {

    Player player=new Player("file:///C:/getg.mp4");
    Scene scene=new Scene(player, 750, 480);
    primaryStage.setScene(scene);
    primaryStage.show();




}

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

}

这是我为Player类开发的代码: 包裹申请;

import javafx.scene.layout.BorderPane;

import javafx.scene.layout.Pane;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;

public class Player extends BorderPane {    
    Media media;
    MediaPlayer player;
    MediaView view;
    Pane mpane;
    public Player(String file){
        media=new Media(file);
        player=new MediaPlayer(media);
        view =new MediaView(player);
        mpane=new Pane();

        mpane.getChildren().add(view);
        setCenter(mpane);

        player.play();


    }

}

这是我生成的错误:

Exception in Application start method  
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplication(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.launcher.LauncherHelper$FXHelper.main(Unknown Source)
Caused by: java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$152(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$50/1323468230.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: MediaException: MEDIA_UNAVAILABLE : C:\getg.mp4 (The system cannot find the file specified)
at javafx.scene.media.Media.<init>(Unknown Source)
at application.Player.<init>(Player.java:16)
at application.Main.start(Main.java:17)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$159(Unknown Source)
at com.sun.javafx.application.LauncherImpl$$Lambda$53/260348613.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$172(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$45/186276003.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$170(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/573945332.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$171(Unknown Source)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/237061348.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$145(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$36/2117255219.run(Unknown Source)
... 1 more
 Exception running application application.Main  

我安装了Java Effects,你觉得怎么回事?

0 个答案:

没有答案