Hi ich versuche gerade es hinzubekommen in ein Jpanel ein video abzuspielen :
komem nur soweit :
läuft aber nicht:rtfm:
komem nur soweit :
Java:
import java.awt.EventQueue;
public class introchose {
private JFrame frame;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
introchose window = new introchose();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public introchose() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 582, 514);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLayeredPane layeredPane = new JLayeredPane();
GroupLayout groupLayout = new GroupLayout(frame.getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(21)
.addComponent(layeredPane, GroupLayout.PREFERRED_SIZE, 521, GroupLayout.PREFERRED_SIZE)
.addContainerGap(24, Short.MAX_VALUE))
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addGap(43)
.addComponent(layeredPane, GroupLayout.DEFAULT_SIZE, 422, Short.MAX_VALUE)
.addContainerGap())
);
final JFXPanel fxPanel = new JFXPanel();
fxPanel.setBounds(23, 11, 488, 344);
layeredPane.add(fxPanel);
frame.setVisible(true);
JButton btnStart = new JButton("start");
btnStart.addActionListener(new ActionListener() {
@SuppressWarnings("deprecation")
public void actionPerformed(ActionEvent arg0) {
String workingDir = System.getProperty("user.dir");
final File f = new File(workingDir, "media/meinvideo.mp4");
final Media m = new Media(f.toURI().toString());
final MediaPlayer mp = new MediaPlayer(m);
final MediaView mv = new MediaView(mp);
final DoubleProperty width = mv.fitWidthProperty();
final DoubleProperty height = mv.fitHeightProperty();
width.bind(Bindings.selectDouble(mv.sceneProperty(), "width"));
height.bind(Bindings.selectDouble(mv.sceneProperty(), "height"));
StackPane root = new StackPane();
root.getChildren().add(mv);
final Scene scene = new Scene(root, 488, 344);
fxPanel.setScene(scene);
mp.play();
}
});
btnStart.setBounds(227, 388, 89, 23);
layeredPane.add(btnStart);
frame.getContentPane().setLayout(groupLayout);
}
}
läuft aber nicht:rtfm: