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

64
LINES

< > BotCompany Repo | #1003708 // JavaFX: Video, Fast, Auto-Resizing, No Buttons v2 (GOOD)

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

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 BorderPane 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.setCenter(mediaView);
63  
  }
64  
}

Author comment

Began life as a copy of #1003707

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
1263 stefan Perfect!! 2016-07-26 00:36:58

add comment

Snippet ID: #1003708
Snippet name: JavaFX: Video, Fast, Auto-Resizing, No Buttons v2 (GOOD)
Eternal ID of this version: #1003708/1
Text MD5: a5ec01f02543d99805d992c174db5b6c
Transpilation MD5: ec597632dd274f220180917736d2fe5a
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 17:52:56
Source code size: 1995 bytes / 64 lines
Pitched / IR pitched: No / No
Views / Downloads: 1329 / 1354
Referenced in: [show references]