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

63
LINES

< > BotCompany Repo | #1003707 // JavaFX: Video, Fast, Auto-Resizing, No Buttons

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

Libraryless. Click here for Pure Java version (110L/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  
    Scene scene = new Scene(new Group(), w, h, Color.BLACK);
31  
    stage.setScene(scene);
32  
33  
    // Name and display the Stage.
34  
    stage.setTitle("Hello Media");
35  
    stage.show();
36  
37  
    // Create the media source.
38  
    //String source = getParameters().getRaw().get(0);
39  
    String source = "/media/CE009E97009E865D__/Downloads/Oblivion (2013)/Oblivion.2013.mp4";
40  
    Media media = null;
41  
    try {
42  
      media = new Media(new File(source).toURI().toURL().toString());
43  
    } catch (MalformedURLException e) {
44  
      throw new RuntimeException(e);
45  
    }
46  
47  
    // Create the player and set to play automatically.
48  
    MediaPlayer mediaPlayer = new MediaPlayer(media);
49  
    mediaPlayer.setAutoPlay(true);
50  
51  
    // Create the media view.
52  
    MediaView mediaView = new MediaView(mediaPlayer);
53  
    
54  
    // Resize Hack
55  
    DoubleProperty mvw = mediaView.fitWidthProperty();
56  
    DoubleProperty mvh = mediaView.fitHeightProperty();
57  
    mvw.bind(Bindings.selectDouble(mediaView.sceneProperty(), "width"));
58  
    mvh.bind(Bindings.selectDouble(mediaView.sceneProperty(), "height"));
59  
    mediaView.setPreserveRatio(true);
60  
  
61  
    ((Group) scene.getRoot()).getChildren().add(mediaView);
62  
  }
63  
}

Author comment

Began life as a copy of #1003706

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
1262 stefan Almost! Just the black is only at right and bottom. 2016-07-26 00:33:56

add comment

Snippet ID: #1003707
Snippet name: JavaFX: Video, Fast, Auto-Resizing, No Buttons
Eternal ID of this version: #1003707/1
Text MD5: d4d17efad063af9676abab30e22abba6
Transpilation MD5: 44a8dbb4b827045c539f081b1732e15d
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:33:22
Source code size: 2005 bytes / 63 lines
Pitched / IR pitched: No / No
Views / Downloads: 854 / 903
Referenced in: [show references]