Libraryless. Click here for Pure Java version (198L/2K/7K).
1 | !759 |
2 | |
3 | import javafx.application.Application; |
4 | import javafx.scene.Group; |
5 | import javafx.scene.Scene; |
6 | import javafx.scene.media.Media; |
7 | import javafx.scene.media.MediaPlayer; |
8 | import javafx.scene.media.MediaView; |
9 | import javafx.stage.Stage; |
10 | import javafx.scene.layout.*; |
11 | import javafx.geometry.Insets; |
12 | import javafx.scene.control.Button; |
13 | import javafx.beans.property.*; |
14 | import javafx.beans.binding.*; |
15 | import javafx.scene.paint.Color; |
16 | |
17 | public class main extends Application { |
18 | p { |
19 | System.setProperty("prism.forceGPU", "true"); |
20 | System.setProperty("prism.verbose", "true"); |
21 | |
22 | fixContextClassLoader(); |
23 | |
24 | thread { |
25 | sleepSeconds(4); |
26 | jfxLater(r { |
27 | print("Starting second app"); |
28 | new main app; |
29 | new Stage stage; |
30 | app.start(stage); |
31 | }); |
32 | } |
33 | |
34 | launch(); |
35 | } |
36 | |
37 | public void start(Stage stage) { |
38 | // Create and set the Scene. |
39 | // Numbers are window size (content is not scaled) |
40 | double w = 540, h = 209; |
41 | new BorderPane root; |
42 | Scene scene = new Scene(root, w, h, Color.BLACK); |
43 | stage.setScene(scene); |
44 | |
45 | // Name and display the Stage. |
46 | stage.setTitle("Hello Media"); |
47 | stage.show(); |
48 | |
49 | // Create the media source. |
50 | //String source = getParameters().getRaw().get(0); |
51 | String source = "/media/CE009E97009E865D__/Downloads/Oblivion (2013)/Oblivion.2013.mp4"; |
52 | Media media = null; |
53 | try { |
54 | media = new Media(new File(source).toURI().toURL().toString()); |
55 | } catch (MalformedURLException e) { |
56 | throw new RuntimeException(e); |
57 | } |
58 | |
59 | // Create the player and set to play automatically. |
60 | MediaPlayer mediaPlayer = new MediaPlayer(media); |
61 | mediaPlayer.setAutoPlay(true); |
62 | |
63 | // Create the media view. |
64 | MediaView mediaView = new MediaView(mediaPlayer); |
65 | |
66 | // Resize Hack |
67 | DoubleProperty mvw = mediaView.fitWidthProperty(); |
68 | DoubleProperty mvh = mediaView.fitHeightProperty(); |
69 | mvw.bind(Bindings.selectDouble(mediaView.sceneProperty(), "width")); |
70 | mvh.bind(Bindings.selectDouble(mediaView.sceneProperty(), "height")); |
71 | mediaView.setPreserveRatio(true); |
72 | |
73 | root.setCenter(mediaView); |
74 | } |
75 | } |
Began life as a copy of #1003708
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003746 |
Snippet name: | Try Playing Two Videos (On 2 JavaFX Stages) - WORKS! |
Eternal ID of this version: | #1003746/1 |
Text MD5: | 7533bc26e132649df9e88587d8c3ed20 |
Transpilation MD5: | 3e8fe03c3f37bcd53f6da5c91e3786a0 |
Author: | stefan |
Category: | javax / javafx |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-07-26 18:03:15 |
Source code size: | 2198 bytes / 75 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 568 / 617 |
Referenced in: | [show references] |