Java Code Examples for javafx.scene.media.MediaView#setFitWidth()

The following examples show how to use javafx.scene.media.MediaView#setFitWidth() . 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: AlphaMediaPlayer.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
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 2
Source File: AlphaMediaPlayer.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
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 3
Source File: MediaPlayerScene.java    From aurous-app with GNU General Public License v2.0 4 votes vote down vote up
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);
	}