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

75
LINES

< > BotCompany Repo | #1003700 // JavaFX: Try Adding Buttons To Video

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

Libraryless. Click here for Pure Java version (122L/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  
14  
public class main extends Application {
15  
  p {
16  
    System.setProperty("prism.forceGPU", "true");
17  
    System.setProperty("prism.verbose", "true");
18  
    
19  
    fixContextClassLoader();
20  
    launch();
21  
  }
22  
23  
  public void start(Stage stage) {
24  
    // Create and set the Scene.
25  
    // Numbers are window size (content is not scaled)
26  
    double w = 540, h = 209;
27  
    Scene scene = new Scene(new Group(), w, h);
28  
    stage.setScene(scene);
29  
30  
    // Name and display the Stage.
31  
    stage.setTitle("Hello Media");
32  
    stage.show();
33  
34  
    // Create the media source.
35  
    //String source = getParameters().getRaw().get(0);
36  
    String source = "/media/CE009E97009E865D__/Downloads/Oblivion (2013)/Oblivion.2013.mp4";
37  
    Media media = null;
38  
    try {
39  
      media = new Media(new File(source).toURI().toURL().toString());
40  
    } catch (MalformedURLException e) {
41  
      throw new RuntimeException(e);
42  
    }
43  
44  
    // Create the player and set to play automatically.
45  
    MediaPlayer mediaPlayer = new MediaPlayer(media);
46  
    mediaPlayer.setAutoPlay(true);
47  
48  
    // Create the media view.
49  
    MediaView mediaView = new MediaView(mediaPlayer);
50  
    
51  
    // Make BorderPane and add to scene.
52  
    BorderPane border = new BorderPane();
53  
    HBox hbox = makeButtons();
54  
    border.setBottom(hbox);
55  
    border.setCenter(mediaView);
56  
    
57  
    ((Group) scene.getRoot()).getChildren().add(border);
58  
  }
59  
  
60  
  HBox makeButtons() {
61  
    new HBox hbox;
62  
    hbox.setPadding(new Insets(15, 12, 15, 12));
63  
    hbox.setSpacing(10);
64  
    hbox.setStyle("-fx-background-color: #336699;");
65  
66  
    Button buttonCurrent = new Button("Current");
67  
    buttonCurrent.setPrefSize(100, 20);
68  
69  
    Button buttonProjected = new Button("Projected");
70  
    buttonProjected.setPrefSize(100, 20);
71  
    hbox.getChildren().addAll(buttonCurrent, buttonProjected);
72  
73  
    return hbox;    
74  
  }
75  
}

Author comment

Began life as a copy of #1003698

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

Comments [hide]

ID Author/Program Comment Date
1256 stefan Nice! Just now resize the scene with the window 2016-07-25 23:54:00

add comment

Snippet ID: #1003700
Snippet name: JavaFX: Try Adding Buttons To Video
Eternal ID of this version: #1003700/1
Text MD5: 7996d53facb18f64852c123dff4f2563
Transpilation MD5: 0ee2b1bf42ba1f656d8ac6f913a80c1d
Author: stefan
Category: javax / javafx
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-07-25 23:53:01
Source code size: 2216 bytes / 75 lines
Pitched / IR pitched: No / No
Views / Downloads: 575 / 597
Referenced in: [show references]