added first layout for SeriesDetailView

This commit is contained in:
2019-06-17 00:44:44 +02:00
parent 656c22d48a
commit 693650fece
12 changed files with 302 additions and 28 deletions

View File

@ -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! ");
}
}
}
}

View File

@ -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");

View File

@ -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")) {

View File

@ -0,0 +1,10 @@
package kellerkinder.HomeFlix.application;
import javafx.fxml.FXML;
import javafx.scene.layout.AnchorPane;
public class SeriesDetailView {
@FXML private AnchorPane seriesDVPane;
}

View File

@ -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<WindowEvent>() {
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"));
}
}

View File

@ -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);
}
/**