Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

65
LINES

< > BotCompany Repo | #1003751 // Experiment with JavaFX launch()

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (118L/2K/5K).

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  
p {
18  
  jfxForceGPU();
19  
  fixContextClassLoader();
20  
  Player._launch();
21  
}
22  
23  
// OK, so they may be inner classes, but must be PUBLIC.
24  
public sclass Player extends Application {
25  
  svoid _launch() { launch(); }
26  
  
27  
  public void start(Stage stage) {
28  
    // Create and set the Scene.
29  
    // Numbers are window size (content is not scaled)
30  
    double w = 540, h = 209;
31  
    new BorderPane root;
32  
    Scene scene = new Scene(root, w, h, Color.BLACK);
33  
    stage.setScene(scene);
34  
35  
    // Name and display the Stage.
36  
    stage.setTitle("Hello Media");
37  
    stage.show();
38  
39  
    // Create the media source.
40  
    //String source = getParameters().getRaw().get(0);
41  
    String source = "/media/CE009E97009E865D__/Downloads/Oblivion (2013)/Oblivion.2013.mp4";
42  
    Media media = null;
43  
    try {
44  
      media = new Media(new File(source).toURI().toURL().toString());
45  
    } catch (MalformedURLException e) {
46  
      throw new RuntimeException(e);
47  
    }
48  
49  
    // Create the player and set to play automatically.
50  
    MediaPlayer mediaPlayer = new MediaPlayer(media);
51  
    mediaPlayer.setAutoPlay(true);
52  
53  
    // Create the media view.
54  
    MediaView mediaView = new MediaView(mediaPlayer);
55  
    
56  
    // Resize Hack
57  
    DoubleProperty mvw = mediaView.fitWidthProperty();
58  
    DoubleProperty mvh = mediaView.fitHeightProperty();
59  
    mvw.bind(Bindings.selectDouble(mediaView.sceneProperty(), "width"));
60  
    mvh.bind(Bindings.selectDouble(mediaView.sceneProperty(), "height"));
61  
    mediaView.setPreserveRatio(true);
62  
  
63  
    root.setCenter(mediaView);
64  
  }
65  
}

Author comment

Began life as a copy of #1003746

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: #1003751
Snippet name: Experiment with JavaFX launch()
Eternal ID of this version: #1003751/1
Text MD5: 06357c444babbb96c08f7d92dcf3a170
Transpilation MD5: ac6e027aad428fe7b40a7bbff8d27830
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 19:09:57
Source code size: 2004 bytes / 65 lines
Pitched / IR pitched: No / No
Views / Downloads: 449 / 547
Referenced in: [show references]