Libraryless. Click here for Pure Java version (111L/2K/4K).
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 | launch(); |
24 | } |
25 | |
26 | public void start(Stage stage) { |
27 | // Create and set the Scene. |
28 | // Numbers are window size (content is not scaled) |
29 | double w = 540, h = 209; |
30 | new Pane root; |
31 | Scene scene = new Scene(root, w, h, Color.BLACK); |
32 | stage.setScene(scene); |
33 | |
34 | // Name and display the Stage. |
35 | stage.setTitle("Hello Media"); |
36 | stage.show(); |
37 | |
38 | // Create the media source. |
39 | //String source = getParameters().getRaw().get(0); |
40 | String source = "/media/CE009E97009E865D__/Downloads/Oblivion (2013)/Oblivion.2013.mp4"; |
41 | Media media = null; |
42 | try { |
43 | media = new Media(new File(source).toURI().toURL().toString()); |
44 | } catch (MalformedURLException e) { |
45 | throw new RuntimeException(e); |
46 | } |
47 | |
48 | // Create the player and set to play automatically. |
49 | MediaPlayer mediaPlayer = new MediaPlayer(media); |
50 | mediaPlayer.setAutoPlay(true); |
51 | |
52 | // Create the media view. |
53 | MediaView mediaView = new MediaView(mediaPlayer); |
54 | |
55 | // Resize Hack |
56 | DoubleProperty mvw = mediaView.fitWidthProperty(); |
57 | DoubleProperty mvh = mediaView.fitHeightProperty(); |
58 | mvw.bind(Bindings.selectDouble(mediaView.sceneProperty(), "width")); |
59 | mvh.bind(Bindings.selectDouble(mediaView.sceneProperty(), "height")); |
60 | mediaView.setPreserveRatio(true); |
61 | |
62 | root.getChildren().add(mediaView); |
63 | } |
64 | } |
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
ID | Author/Program | Comment | Date |
---|---|---|---|
1264 | stefan | No better than v1. Use v2!! | 2016-07-26 00:38:01 |
Snippet ID: | #1003709 |
Snippet name: | JavaFX: Video, Fast, Auto-Resizing, No Buttons v1.5 |
Eternal ID of this version: | #1003709/1 |
Text MD5: | e3d83caee5654cbd0ac902d2a764ef4d |
Transpilation MD5: | c3c4babfa707e5b558e09edfc2277759 |
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 00:37:32 |
Source code size: | 1997 bytes / 64 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 760 / 789 |
Referenced in: | [show references] |