minor fixes

* fixed streaming not working under linux
* minor text fixes
This commit is contained in:
Jannik 2017-07-20 14:23:50 +02:00
parent d92c496fe2
commit 1f02277f72
10 changed files with 70 additions and 57 deletions

1
bin/.gitignore vendored
View File

@ -1,2 +1 @@
/application/ /application/
/resources/

View File

@ -266,58 +266,65 @@ public class MainWindowController {
private apiQuery ApiQuery; private apiQuery ApiQuery;
DBController dbController; DBController dbController;
//TODO add streaming support to Linux!
@FXML @FXML
private void playbtnclicked(){ private void playbtnclicked(){
System.out.println(System.getProperty("os.name")); if (mode.equals("streaming")) {
if(System.getProperty("os.name").contains("Linux")){ if (Desktop.isDesktopSupported()) {
System.out.println("This is "+System.getProperty("os.name")); new Thread(() -> {
String line; try {
String output = ""; Desktop.getDesktop().browse(new URI(datPath)); //open the streaming URL in browser
Process p; } catch (IOException | URISyntaxException e) {
try { e.printStackTrace();
p = Runtime.getRuntime().exec("which vlc"); showErrorMsg(errorOpenStream, (IOException) e);
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); }
while ((line = input.readLine()) != null) { }).start();
output = line; } else {
} System.out.println("Desktop not supported");
System.out.println(output);
input.close();
} catch (IOException e1) {
e1.printStackTrace();
} }
if(output.contains("which: no vlc")||output == ""){ }else if (mode.equals("local")) {
Alert alert = new Alert(AlertType.INFORMATION); if(System.getProperty("os.name").contains("Linux")){
alert.setHeaderText(""); System.out.println("This is "+System.getProperty("os.name"));
alert.setTitle("Info"); String line;
alert.setContentText(vlcNotInstalled); String output = "";
alert.showAndWait(); Process p;
}else{
try { try {
Runtime.getRuntime().exec(new String[] { "vlc", getPath()+"/"+ datPath}); p = Runtime.getRuntime().exec("which vlc");
} catch (IOException e) { BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
showErrorMsg(errorPlay,e); while ((line = input.readLine()) != null) {
output = line;
}
System.out.println(output);
input.close();
} catch (IOException e1) {
e1.printStackTrace();
} }
} if(output.contains("which: no vlc")||output == ""){
}else if(System.getProperty("os.name").contains("Windows") || System.getProperty("os.name").contains("Mac OS X")){ Alert alert = new Alert(AlertType.INFORMATION);
System.out.println("This is "+System.getProperty("os.name")); alert.setHeaderText("");
if(mode.equals("local")){ alert.setTitle("Info");
try { alert.setContentText(vlcNotInstalled);
Desktop.getDesktop().open(new File(getPath()+"\\"+ datPath)); alert.showAndWait();
} catch (IOException e) { }else{
showErrorMsg(errorPlay,e); try {
Runtime.getRuntime().exec(new String[] { "vlc", getPath()+"/"+ datPath});
} catch (IOException e) {
showErrorMsg(errorPlay,e);
}
} }
}else if(mode.equals("streaming")){ }else if(System.getProperty("os.name").contains("Windows") || System.getProperty("os.name").contains("Mac OS X")){
try { System.out.println("This is "+System.getProperty("os.name"));
Desktop.getDesktop().browse(new URI(datPath)); //open the streaming URL in browser try {
} catch (URISyntaxException | IOException e) { Desktop.getDesktop().open(new File(getPath()+"\\"+ datPath));
showErrorMsg(errorOpenStream, (IOException) e); } catch (IOException e) {
} showErrorMsg(errorPlay,e);
}else{ }
IOException e = new IOException("error"); } else {
showErrorMsg(errorMode, e); System.out.println("It seems like your operating system is not supported, please contact a developer!");
System.out.println("Error code is: nsos; OS is: " + System.getProperty("os.name"));
} }
} else {
IOException e = new IOException("error");
showErrorMsg(errorMode, e);
} }
} }
@ -495,7 +502,6 @@ public class MainWindowController {
} }
//Initialize the tables (treeTableViewfilm and tableViewStreamingdata) //Initialize the tables (treeTableViewfilm and tableViewStreamingdata)
@SuppressWarnings({ "unchecked"}) //TODO
void initTabel(){ void initTabel(){
//film Table //film Table
@ -519,10 +525,17 @@ public class MainWindowController {
columnSeason.setCellValueFactory(cellData -> cellData.getValue().getValue().seasonProperty().asObject()); columnSeason.setCellValueFactory(cellData -> cellData.getValue().getValue().seasonProperty().asObject());
columnEpisode.setCellValueFactory(cellData -> cellData.getValue().getValue().episodeProperty().asObject()); columnEpisode.setCellValueFactory(cellData -> cellData.getValue().getValue().episodeProperty().asObject());
treeTableViewfilm.getColumns().addAll(columnTitel, columnRating, columnStreamUrl, columnResolution, columnYear, columnSeason, columnEpisode); //add columns to treeTableViewfilm
treeTableViewfilm.getColumns().get(2).setVisible(false); //hide columnStreamUrl (column with file path important for the player) treeTableViewfilm.getColumns().add(columnTitel);
treeTableViewfilm.getColumns().add(columnRating);
treeTableViewfilm.getColumns().add(columnStreamUrl);
treeTableViewfilm.getColumns().add(columnResolution);
treeTableViewfilm.getColumns().add(columnYear);
treeTableViewfilm.getColumns().add(columnSeason);
treeTableViewfilm.getColumns().add(columnEpisode);
treeTableViewfilm.getColumns().get(2).setVisible(false); //hide columnStreamUrl (column with file URL, important for opening a file/stream)
//Change-listener for TreeTable //Change-listener for treeTableViewfilm
treeTableViewfilm.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() { treeTableViewfilm.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Object>() {
@Override @Override
public void changed(ObservableValue<?> observable, Object oldVal, Object newVal){ public void changed(ObservableValue<?> observable, Object oldVal, Object newVal){
@ -552,14 +565,15 @@ public class MainWindowController {
} }
}); });
//context menu for treetableview //context menu for treeTableViewfilm
treeTableViewfilm.setContextMenu(menu); treeTableViewfilm.setContextMenu(menu);
//Streaming-Settings Table //Streaming-Settings Table
dataNameColumn.setCellValueFactory(cellData -> cellData.getValue().titleProperty()); dataNameColumn.setCellValueFactory(cellData -> cellData.getValue().titleProperty());
dataNameEndColumn.setCellValueFactory(cellData -> cellData.getValue().streamUrlProperty()); dataNameEndColumn.setCellValueFactory(cellData -> cellData.getValue().streamUrlProperty());
tableViewStreamingdata.getColumns().addAll(dataNameColumn, dataNameEndColumn); tableViewStreamingdata.getColumns().add(dataNameColumn);
tableViewStreamingdata.getColumns().add(dataNameEndColumn);
tableViewStreamingdata.setItems(streamingData); tableViewStreamingdata.setItems(streamingData);
} }
@ -660,7 +674,7 @@ public class MainWindowController {
Alert alert = new Alert(AlertType.ERROR); Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Error"); alert.setTitle("Error");
alert.setHeaderText(""); alert.setHeaderText("");
alert.setContentText("There should be an error message in the future (like problem)\nIt seems as a cat has stolen the like-methode"); alert.setContentText("There should be an error message in future (like-problem).\nIt seems as a cat has stolen the \"like-methode\"!");
e.printStackTrace(); e.printStackTrace();
} }
refreshTable(); refreshTable();
@ -682,7 +696,7 @@ public class MainWindowController {
Alert alert = new Alert(AlertType.ERROR); Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Error"); alert.setTitle("Error");
alert.setHeaderText(""); alert.setHeaderText("");
alert.setContentText("There should be an error message in the future (dislike problem)"); alert.setContentText("There should be an error message in future (dislike problem)");
e.printStackTrace(); e.printStackTrace();
} }
refreshTable(); refreshTable();
@ -700,7 +714,7 @@ public class MainWindowController {
ArrayList<Integer> fav_false = new ArrayList<Integer>(); ArrayList<Integer> fav_false = new ArrayList<Integer>();
ObservableList<tableData> helpData; ObservableList<tableData> helpData;
filterData.removeAll(filterData); filterData.removeAll(filterData);
// treeTableViewfilm.getSelectionModel().clearSelection(selected); // treeTableViewfilm.getSelectionModel().clearSelection(selected);
root.getChildren().remove(0,root.getChildren().size()); root.getChildren().remove(0,root.getChildren().size());
if(mode.equals("local")){ if(mode.equals("local")){