/* * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. */ import javafx.application.Application; import javafx.scene.*; import javafx.scene.media.MediaPlayer; import javafx.scene.media.Media; import javafx.scene.media.MediaView; import javafx.stage.Stage; /** * * @author mrkam */ public class VideoBallApp extends Application { public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) throws Exception { VideoBall.MediaBall mediaBall = new VideoBall.MediaBall(); Scene scene = new Scene(mediaBall); scene.setCamera(new PerspectiveCamera()); stage.setScene(scene); stage.show(); } public static abstract class VideoBall extends Group { public static final float RADIUS = 438; public static final int WIDTH = 96; public static final int HEIGHT = WIDTH / 16 * 9; public final int ROW_COUNT = (int) (Math.PI * RADIUS / HEIGHT) - 1; public VideoBall() { Group group = new Group(); group.getChildren().setAll(createNode(0, 0, 0)); getChildren().setAll(group); // Rectangle{ width: 100, height: 100, x: -50, y: -50 } System.out.println("BALL NODE COUNT = " + ((Group) getChildren().get(0)).getChildren().size()); } public abstract Node createNode(int index, int col, int row); public static class MediaBall extends VideoBall { private final int MEDIA_IN_ROW = 1920 / WIDTH; private MediaPlayer mediaPlayer; { // initMediaPlayer(); // option 1 } public MediaBall() { // initMediaPlayer(); // option 2 } public void initMediaPlayer() { System.out.println("Thread = " + Thread.currentThread()); Media media = new Media("file:///D:/JavaFX/demo/data/EarthComp_highRes.flv"); mediaPlayer = new MediaPlayer( // new Media("http://reavers.us.oracle.com/flv/EarthComp_highRes.flv")); media); } @Override public Node createNode(int index, int col, int row) { initMediaPlayer(); // option 3 MediaView mediaView = new MediaView(mediaPlayer); // mediaView.setFitWidth(WIDTH); // mediaView.setFitHeight(HEIGHT); // mediaView.setViewport(new Rectangle2D(index % MEDIA_IN_ROW * WIDTH, index / MEDIA_IN_ROW * HEIGHT, WIDTH, HEIGHT)); return mediaView; } } } }