2018-04-02 18:29:59 +02:00
/ * *
* Project - HomeFlix
*
* Copyright 2016 - 2018 < @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 .
*
* /
2018-04-01 23:24:49 +02:00
package kellerkinder.HomeFlix.player ;
import javafx.event.EventHandler ;
import javafx.fxml.FXMLLoader ;
import javafx.scene.Parent ;
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 ;
2018-04-07 17:14:35 +02:00
import kellerkinder.HomeFlix.application.MainWindowController ;
2018-04-01 23:24:49 +02:00
public class Player {
private PlayerController playerController ;
private Stage stage ;
private AnchorPane pane ;
2018-04-02 02:18:43 +02:00
private Scene scene ;
2018-04-01 23:24:49 +02:00
2018-04-02 18:29:59 +02:00
/ * *
* generate a new PlayerWindow
2018-04-07 17:14:35 +02:00
* @param mainWindowController the MainWindowController
2018-04-02 18:29:59 +02:00
* /
2018-04-07 17:14:35 +02:00
public Player ( MainWindowController mainWindowController ) {
2018-04-01 23:24:49 +02:00
try {
FXMLLoader fxmlLoader = new FXMLLoader ( ClassLoader . getSystemResource ( " fxml/PlayerWindow.fxml " ) ) ;
pane = ( AnchorPane ) fxmlLoader . load ( ) ;
stage = new Stage ( ) ;
2018-04-02 02:18:43 +02:00
scene = new Scene ( pane ) ;
stage . setScene ( scene ) ;
2018-04-01 23:24:49 +02:00
stage . setTitle ( " HomeFlix " ) ;
stage . getIcons ( ) . add ( new Image ( Main . class . getResourceAsStream ( " /icons/Homeflix_Icon_64x64.png " ) ) ) ;
stage . setOnCloseRequest ( new EventHandler < WindowEvent > ( ) {
public void handle ( WindowEvent we ) {
2018-04-07 17:14:35 +02:00
mainWindowController . getDbController ( ) . setCurrentTime ( mainWindowController . getCurrentStreamUrl ( ) ,
playerController . getCurrentTime ( ) ) ;
2018-04-01 23:24:49 +02:00
playerController . getMediaPlayer ( ) . stop ( ) ;
2018-04-02 02:18:43 +02:00
stage . close ( ) ;
2018-04-01 23:24:49 +02:00
}
} ) ;
playerController = fxmlLoader . getController ( ) ;
2018-04-07 17:14:35 +02:00
playerController . init ( mainWindowController , this , mainWindowController . getCurrentTableFilm ( ) ) ;
2018-04-01 23:24:49 +02:00
stage . setFullScreen ( true ) ;
stage . show ( ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
}
}
public Stage getStage ( ) {
return stage ;
}
public Parent getPane ( ) {
return pane ;
}
2018-04-02 02:18:43 +02:00
public Scene getScene ( ) {
return scene ;
}
2018-04-01 23:24:49 +02:00
}