javafx.scene.media.MediaView Java Examples
The following examples show how to use
javafx.scene.media.MediaView.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HtmlWebView.java From Learn-Java-12-Programming with MIT License | 9 votes |
public void start11(Stage primaryStage) { Text txt1 = new Text("What a beautiful music!"); Text txt2 = new Text("If you don't hear music, turn up the volume."); File f = new File("src/main/resources/jb.mp3"); Media m = new Media(f.toURI().toString()); MediaPlayer mp = new MediaPlayer(m); MediaView mv = new MediaView(mp); VBox vb = new VBox(txt1, txt2, mv); vb.setSpacing(20); vb.setAlignment(Pos.CENTER); vb.setPadding(new Insets(10, 10, 10, 10)); Scene scene = new Scene(vb, 350, 100); primaryStage.setScene(scene); primaryStage.setTitle("JavaFX with embedded media player"); primaryStage.onCloseRequestProperty() .setValue(e -> System.out.println("Bye! See you later!")); primaryStage.show(); mp.play(); }
Example #2
Source File: HtmlWebView.java From Learn-Java-12-Programming with MIT License | 5 votes |
public void start12(Stage primaryStage) { Text txt = new Text("What a beautiful movie!"); File f = new File("src/main/resources/sea.mp4"); Media m = new Media(f.toURI().toString()); MediaPlayer mp = new MediaPlayer(m); MediaView mv = new MediaView(mp); //mv.autosize(); //mv.preserveRatioProperty(); //mv.setFitHeight(); //mv.setFitWidth(); //mv.fitWidthProperty(); //mv.fitHeightProperty() VBox vb = new VBox(txt, mv); vb.setSpacing(20); vb.setAlignment(Pos.CENTER); vb.setPadding(new Insets(10, 10, 10, 10)); Scene scene = new Scene(vb, 650, 400); primaryStage.setScene(scene); primaryStage.setTitle("JavaFX with embedded media player"); primaryStage.onCloseRequestProperty() .setValue(e -> System.out.println("Bye! See you later!")); primaryStage.show(); mp.play(); }
Example #3
Source File: HtmlWebView.java From Learn-Java-12-Programming with MIT License | 5 votes |
public void start13(Stage primaryStage) { Text txt1 = new Text("What a beautiful movie and sound!"); Text txt2 = new Text("If you don't hear music, turn up the volume."); File fs = new File("src/main/resources/jb.mp3"); Media ms = new Media(fs.toURI().toString()); MediaPlayer mps = new MediaPlayer(ms); MediaView mvs = new MediaView(mps); File fv = new File("src/main/resources/sea.mp4"); Media mv = new Media(fv.toURI().toString()); MediaPlayer mpv = new MediaPlayer(mv); MediaView mvv = new MediaView(mpv); VBox vb = new VBox(txt1, txt2, mvs, mvv); vb.setSpacing(20); vb.setAlignment(Pos.CENTER); vb.setPadding(new Insets(10, 10, 10, 10)); Scene scene = new Scene(vb, 650, 500); primaryStage.setScene(scene); primaryStage.setTitle("JavaFX with embedded media player"); primaryStage.onCloseRequestProperty() .setValue(e -> System.out.println("Bye! See you later!")); primaryStage.show(); mpv.play(); mps.play(); }
Example #4
Source File: AlphaMediaPlayer.java From marathonv5 with Apache License 2.0 | 5 votes |
private static Group createViewer(final MediaPlayer player, final double scale, boolean blur) { Group mediaGroup = new Group(); final MediaView mediaView = new MediaView(player); if (blur) { BoxBlur bb = new BoxBlur(); bb.setWidth(4); bb.setHeight(4); bb.setIterations(1); mediaView.setEffect(bb); } double width = player.getMedia().getWidth(); double height = player.getMedia().getHeight(); mediaView.setFitWidth(width); mediaView.setTranslateX(-width/2.0); mediaView.setScaleX(-scale); mediaView.setFitHeight(height); mediaView.setTranslateY(-height/2.0); mediaView.setScaleY(scale); mediaView.setDepthTest(DepthTest.ENABLE); mediaGroup.getChildren().add(mediaView); return mediaGroup; }
Example #5
Source File: AlphaMediaPlayer.java From marathonv5 with Apache License 2.0 | 5 votes |
private static Group createViewer(final MediaPlayer player, final double scale, boolean blur) { Group mediaGroup = new Group(); final MediaView mediaView = new MediaView(player); if (blur) { BoxBlur bb = new BoxBlur(); bb.setWidth(4); bb.setHeight(4); bb.setIterations(1); mediaView.setEffect(bb); } double width = player.getMedia().getWidth(); double height = player.getMedia().getHeight(); mediaView.setFitWidth(width); mediaView.setTranslateX(-width/2.0); mediaView.setScaleX(-scale); mediaView.setFitHeight(height); mediaView.setTranslateY(-height/2.0); mediaView.setScaleY(scale); mediaView.setDepthTest(DepthTest.ENABLE); mediaGroup.getChildren().add(mediaView); return mediaGroup; }
Example #6
Source File: MediaSimplPane.java From oim-fx with MIT License | 4 votes |
private void initPanel() { mediaView = new MediaView(); getChildren().add(mediaView); }
Example #7
Source File: MediaPlayerScene.java From aurous-app with GNU General Public License v2.0 | 4 votes |
public Scene createScene(final String sourceURL) throws Throwable { final Group root = new Group(); root.autosize(); MediaUtils.activeMedia = sourceURL; final String trailer = MediaUtils.getMediaURL(sourceURL); media = new Media(trailer); player = new MediaPlayer(media); view = new MediaView(player); view.setFitWidth(1); view.setFitHeight(1); view.setPreserveRatio(false); // System.out.println("media.width: "+media.getWidth()); final Scene scene = new Scene(root, 1, 1, Color.BLACK); player.play(); player.setOnReady(() -> { ControlPanel.seek().setValue(0); }); player.currentTimeProperty().addListener( (observableValue, duration, current) -> { final long currentTime = (long) current.toMillis(); final long totalDuration = (long) player.getMedia() .getDuration().toMillis(); updateTime(currentTime, totalDuration); }); // PlayerUtils.activeYoutubeVideo = youtubeVideo; if (sourceURL.equals("https://www.youtube.com/watch?v=kGubD7KG9FQ")) { player.pause(); } UISession.setMediaPlayer(player); UISession.setMediaView(view); UISession.setMedia(media); return (scene); }
Example #8
Source File: UISession.java From aurous-app with GNU General Public License v2.0 | 4 votes |
public static MediaView getMediaView() { return mediaView; }
Example #9
Source File: UISession.java From aurous-app with GNU General Public License v2.0 | 4 votes |
public static void setMediaView(final MediaView mediaView) { UISession.mediaView = mediaView; }