series work

if there is more than one season of a series homeflix should manage that too
This commit is contained in:
Jannik 2018-04-15 21:30:26 +02:00
parent 94e32b938a
commit 0c1b21ac05
3 changed files with 35 additions and 14 deletions

View File

@ -218,9 +218,9 @@ public class MainWindowController {
private static final Logger LOGGER = LogManager.getLogger(MainWindowController.class.getName());
private int hashA = -647380320;
private String version = "0.6.99";
private String buildNumber = "147";
private String versionName = "glowing vampire";
private String version = "0.6.100";
private String buildNumber = "149";
private String versionName = "toothless dragon RC";
private String dialogBtnStyle;
private String color;
private String local;

View File

@ -541,6 +541,11 @@ public class DBController {
}
}
/**
* checks if there is already a entry with the given streamUrl in the cache
* @param streamUrl URL of the element
* @return true if the element is already cached, else false
*/
public boolean searchCache(String streamUrl) {
boolean retValue = false;
try {
@ -661,27 +666,42 @@ public class DBController {
}
}
/**
/** TODO check if we relay need to separate between favorites and none favorites
* get the next episode of a
* @param title URL of the film
* @param nextEp number of the next episode
* @return {@link FilmTabelDataType} the next episode as object
*/
public FilmTabelDataType getNextEpisode(String title, int nextEp) {
public FilmTabelDataType getNextEpisode(String title, int nextEp, int season) {
FilmTabelDataType nextFilm = null;
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM films WHERE title = \"" + title + "\" AND episode = \"" + nextEp + "\";");
while (rs.next()) {
ResultSet rs = stmt.executeQuery("SELECT * FROM films WHERE title = \"" + title + "\" AND episode = \""
+ nextEp + "\" AND season = \"" + season + "\";");
if (rs.next()) {
if (rs.getBoolean("favorite") == true) {
nextFilm = new FilmTabelDataType(rs.getString("streamUrl"),
rs.getString("title"), rs.getString("season"), rs.getString("episode") ,rs.getBoolean("favorite"),
nextFilm = new FilmTabelDataType(rs.getString("streamUrl"), rs.getString("title"),
rs.getString("season"), rs.getString("episode"), rs.getBoolean("favorite"),
rs.getBoolean("cached"), new ImageView(favorite_black));
} else {
nextFilm = new FilmTabelDataType(rs.getString("streamUrl"),
rs.getString("title"), rs.getString("season"), rs.getString("episode"), rs.getBoolean("favorite"),
nextFilm = new FilmTabelDataType(rs.getString("streamUrl"), rs.getString("title"),
rs.getString("season"), rs.getString("episode"), rs.getBoolean("favorite"),
rs.getBoolean("cached"), new ImageView(favorite_border_black));
}
} else {
rs = stmt.executeQuery("SELECT * FROM films WHERE title = \"" + title
+ "\" AND episode = \"1\" AND season = \"" + (season + 1) + "\";");
while (rs.next()) {
if (rs.getBoolean("favorite") == true) {
nextFilm = new FilmTabelDataType(rs.getString("streamUrl"), rs.getString("title"),
rs.getString("season"), rs.getString("episode"), rs.getBoolean("favorite"),
rs.getBoolean("cached"), new ImageView(favorite_black));
} else {
nextFilm = new FilmTabelDataType(rs.getString("streamUrl"), rs.getString("title"),
rs.getString("season"), rs.getString("episode"), rs.getBoolean("favorite"),
rs.getBoolean("cached"), new ImageView(favorite_border_black));
}
}
}
rs.close();
stmt.close();
@ -691,7 +711,7 @@ public class DBController {
return nextFilm;
}
/**
/** TODO check if we relay need to separate between favorites and none favorites
* get the last watched episode
* @param title the title of the series
* @return the last watched episode as {@link FilmTabelDataType} object

View File

@ -143,12 +143,13 @@ public class PlayerController {
public void changed(ObservableValue<? extends Duration> observable, Duration oldValue, Duration newValue) {
currentTime = newValue.toMillis(); // set the current time
int episode = !film.getEpisode().isEmpty() ? Integer.parseInt(film.getEpisode()) : 0;
int season = !film.getSeason().isEmpty() ? Integer.parseInt(film.getSeason()) : 0;
// if we are end time -10 seconds, do autoplay, if activated
if ((duration - currentTime) < 10000 && episode != 0 && autoplay) {
autoplay = false;
mainWCon.getDbController().setCurrentTime(film.getStreamUrl(), 0); // reset old video start time
FilmTabelDataType nextFilm = mainWCon.getDbController().getNextEpisode(film.getTitle(), (episode + 1));
FilmTabelDataType nextFilm = mainWCon.getDbController().getNextEpisode(film.getTitle(), (episode + 1), season);
if (nextFilm != null) {
mediaPlayer.stop();
init(mainWCon, player, nextFilm);