diff --git a/src/main/java/kellerkinder/HomeFlix/application/FilmDetailView.java b/src/main/java/kellerkinder/HomeFlix/application/FilmDetailView.java index e8f4299..1dae333 100644 --- a/src/main/java/kellerkinder/HomeFlix/application/FilmDetailView.java +++ b/src/main/java/kellerkinder/HomeFlix/application/FilmDetailView.java @@ -1,8 +1,10 @@ package kellerkinder.HomeFlix.application; import java.awt.Desktop; +import java.io.BufferedReader; import java.io.File; import java.io.IOException; +import java.io.InputStreamReader; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -19,6 +21,7 @@ import javafx.scene.text.Text; import javafx.util.Duration; import kellerkinder.HomeFlix.controller.DBController; import kellerkinder.HomeFlix.controller.XMLController; +import kellerkinder.HomeFlix.player.Player; public class FilmDetailView { @@ -52,7 +55,7 @@ public class FilmDetailView { @FXML private JFXButton btnPlay; @FXML private JFXButton btnDirectory; - @FXML private ImageView wishListIcon; + @FXML private ImageView wishlistIcon; @FXML private ImageView favoriteIcon; @FXML private ImageView imgPoster; @@ -192,8 +195,53 @@ public class FilmDetailView { MainWindowController.getInstance().disableBlur(); // disable blur } + // TODO rework private void playFilm() { + if(new File(currentStreamURL).isDirectory()) { + return; + } + if (Player.isSupportedFormat(currentStreamURL)) { + new Player(currentStreamURL); + } else { + LOGGER.error("using fallback player!"); + if (System.getProperty("os.name").contains("Linux")) { + String line; + String output = ""; + Process p; + try { + p = Runtime.getRuntime().exec("which vlc"); + BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); + while ((line = input.readLine()) != null) { + output = line; + } + LOGGER.info("which vlc: " + output); + input.close(); + } catch (IOException e1) { + e1.printStackTrace(); + } + if (output.contains("which: no vlc") || output == "") { +// JFXInfoAlert vlcInfoAlert = new JFXInfoAlert("Info", +// XMLController.getLocalBundle().getString("vlcNotInstalled"), btnStyle, primaryStage); +// vlcInfoAlert.showAndWait(); + } else { + try { + new ProcessBuilder("vlc", currentStreamURL).start(); + } catch (IOException e) { + LOGGER.warn("An error has occurred while opening the file!", e); + } + } + + } else if (System.getProperty("os.name").contains("Windows") || System.getProperty("os.name").contains("Mac OS X")) { + try { + Desktop.getDesktop().open(new File(currentStreamURL)); + } catch (IOException e) { + LOGGER.warn("An error has occurred while opening the file!", e); + } + } else { + LOGGER.error(System.getProperty("os.name") + ", OS is not supported, please contact a developer! "); + } + } } } diff --git a/src/main/java/kellerkinder/HomeFlix/application/Main.java b/src/main/java/kellerkinder/HomeFlix/application/Main.java index 2d580c6..e280d72 100644 --- a/src/main/java/kellerkinder/HomeFlix/application/Main.java +++ b/src/main/java/kellerkinder/HomeFlix/application/Main.java @@ -72,7 +72,7 @@ public class Main extends Application { FXMLLoader loader = new FXMLLoader(); loader.setLocation(getClass().getResource("/fxml/MainWindow.fxml")); pane = (AnchorPane) loader.load(); - primaryStage.setMinHeight(600.00); + primaryStage.setMinHeight(600.00 + 34); // 34 -> window decoration primaryStage.setMinWidth(1130.00); //primaryStage.setResizable(false); primaryStage.setTitle("Project HomeFlix"); diff --git a/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java b/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java index e9f324e..3e88eae 100644 --- a/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java +++ b/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java @@ -237,7 +237,7 @@ public class MainWindowController { // load sources list in gui addSourceToTable(); -// posterModeStartup(); // TODO testing DO NOT USE THIS!! + posterModeStartup(); // TODO testing DO NOT USE THIS!! } // Initialize general UI elements @@ -460,7 +460,7 @@ public class MainWindowController { } if (isSupportedFormat(currentTableFilm)) { - new Player(getCurrentTableFilm()); + new Player(getCurrentStreamUrl()); } else { LOGGER.error("using fallback player!"); if (System.getProperty("os.name").contains("Linux")) { diff --git a/src/main/java/kellerkinder/HomeFlix/application/SeriesDetailView.java b/src/main/java/kellerkinder/HomeFlix/application/SeriesDetailView.java new file mode 100644 index 0000000..9de452d --- /dev/null +++ b/src/main/java/kellerkinder/HomeFlix/application/SeriesDetailView.java @@ -0,0 +1,10 @@ +package kellerkinder.HomeFlix.application; + +import javafx.fxml.FXML; +import javafx.scene.layout.AnchorPane; + +public class SeriesDetailView { + + @FXML private AnchorPane seriesDVPane; + +} diff --git a/src/main/java/kellerkinder/HomeFlix/player/Player.java b/src/main/java/kellerkinder/HomeFlix/player/Player.java index b585d36..a49be2c 100644 --- a/src/main/java/kellerkinder/HomeFlix/player/Player.java +++ b/src/main/java/kellerkinder/HomeFlix/player/Player.java @@ -22,16 +22,15 @@ package kellerkinder.HomeFlix.player; -import javafx.event.EventHandler; +import java.net.URLConnection; + 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 { @@ -44,8 +43,8 @@ public class Player { * generate a new PlayerWindow * @param currentTableFilm the currently selected film */ - public Player(FilmTabelDataType currentTableFilm) { - playerController = new PlayerController(this, currentTableFilm); + public Player(String streamURL) { + playerController = new PlayerController(this, streamURL); try { FXMLLoader fxmlLoader = new FXMLLoader(); @@ -57,13 +56,10 @@ public class Player { 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(); - } + stage.setOnCloseRequest(event -> { + DBController.getInstance().setCurrentTime(streamURL, playerController.getCurrentTime()); + playerController.getMediaPlayer().stop(); + stage.close(); }); playerController.init(); @@ -83,4 +79,16 @@ public class Player { return scene; } + /** + * check if a film is supported by the HomeFlixPlayer or not this is the case if + * the mime type is mp4 + * + * @param entry the film you want to check + * @return true if so, false if not + */ + public static boolean isSupportedFormat(String streamURL) { + String mimeType = URLConnection.guessContentTypeFromName(streamURL); + return mimeType != null && (mimeType.contains("mp4") || mimeType.contains("vp6")); + } + } diff --git a/src/main/java/kellerkinder/HomeFlix/player/PlayerController.java b/src/main/java/kellerkinder/HomeFlix/player/PlayerController.java index cb63d4a..54e1db8 100644 --- a/src/main/java/kellerkinder/HomeFlix/player/PlayerController.java +++ b/src/main/java/kellerkinder/HomeFlix/player/PlayerController.java @@ -94,9 +94,9 @@ public class PlayerController { * @param player the player object (needed for closing action) * @param film the film object */ - public PlayerController(Player player, FilmTabelDataType film) { + public PlayerController(Player player, String streamURL) { this.player = player; - this.film = film; + this.film = DBController.getInstance().getStream(streamURL); } /** diff --git a/src/main/resources/fxml/FilmDetailView.fxml b/src/main/resources/fxml/FilmDetailView.fxml index 0674e8f..8034899 100644 --- a/src/main/resources/fxml/FilmDetailView.fxml +++ b/src/main/resources/fxml/FilmDetailView.fxml @@ -2,7 +2,6 @@ - @@ -89,7 +88,7 @@ - - - + - + diff --git a/src/main/resources/fxml/SeriesDetailView.fxml b/src/main/resources/fxml/SeriesDetailView.fxml new file mode 100644 index 0000000..c7cf83e --- /dev/null +++ b/src/main/resources/fxml/SeriesDetailView.fxml @@ -0,0 +1,212 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/icons/2QjWeU6mfvx6sWF2z9CLb4kdRnR.jpg b/src/main/resources/icons/2QjWeU6mfvx6sWF2z9CLb4kdRnR.jpg new file mode 100644 index 0000000..4394dc5 Binary files /dev/null and b/src/main/resources/icons/2QjWeU6mfvx6sWF2z9CLb4kdRnR.jpg differ diff --git a/src/main/resources/icons/baseline_keyboard_arrow_down_white_48dp_48x16.png b/src/main/resources/icons/baseline_keyboard_arrow_down_white_48dp_48x16.png new file mode 100644 index 0000000..e4c34b3 Binary files /dev/null and b/src/main/resources/icons/baseline_keyboard_arrow_down_white_48dp_48x16.png differ diff --git a/src/main/resources/icons/spider-man.jpg b/src/main/resources/icons/spider-man.jpg deleted file mode 100644 index 8f11ab6..0000000 Binary files a/src/main/resources/icons/spider-man.jpg and /dev/null differ