/** * Project-HomeFlix * * Copyright 2016-2019 <@Seil0> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. * */ package kellerkinder.HomeFlix.player; import javafx.event.EventHandler; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.layout.AnchorPane; import javafx.stage.Stage; import javafx.stage.WindowEvent; import kellerkinder.HomeFlix.application.Main; import kellerkinder.HomeFlix.controller.DBController; import kellerkinder.HomeFlix.datatypes.FilmTabelDataType; public class Player { private PlayerController playerController; private Stage stage; private AnchorPane pane; private Scene scene; /** * generate a new PlayerWindow * @param currentTableFilm the currently selected film */ public Player(FilmTabelDataType currentTableFilm) { playerController = new PlayerController(this, currentTableFilm); try { FXMLLoader fxmlLoader = new FXMLLoader(); fxmlLoader.setLocation(getClass().getResource("/fxml/PlayerWindow.fxml")); fxmlLoader.setController(playerController); pane = (AnchorPane) fxmlLoader.load(); stage = new Stage(); scene = new Scene(pane); stage.setScene(scene); stage.setTitle("HomeFlix"); stage.getIcons().add(new Image(Main.class.getResourceAsStream("/icons/Homeflix_Icon_64x64.png"))); stage.setOnCloseRequest(new EventHandler() { public void handle(WindowEvent we) { DBController.getInstance().setCurrentTime(currentTableFilm.getStreamUrl(), playerController.getCurrentTime()); playerController.getMediaPlayer().stop(); stage.close(); } }); playerController.init(); stage.setFullScreen(true); stage.show(); } catch (Exception e) { e.printStackTrace(); } } public Stage getStage() { return stage; } public Scene getScene() { return scene; } }