Browse Source

add subtitle support to player; update log4j to version 2.17.1

dev
Jannik 4 months ago
parent
commit
d167b60661
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
  1. 4
      pom.xml
  2. 2
      src/main/java/org/mosad/homeflix/application/Main.java
  3. 2
      src/main/java/org/mosad/homeflix/application/MainWindowController.java
  4. 2
      src/main/java/org/mosad/homeflix/application/SettingsView.java
  5. 2
      src/main/java/org/mosad/homeflix/application/view/FilmDetailView.java
  6. 2
      src/main/java/org/mosad/homeflix/application/view/SeriesDetailView.java
  7. 2
      src/main/java/org/mosad/homeflix/controller/DBController.java
  8. 2
      src/main/java/org/mosad/homeflix/controller/SourcesController.java
  9. 2
      src/main/java/org/mosad/homeflix/controller/XMLController.java
  10. 2
      src/main/java/org/mosad/homeflix/datatypes/DatabaseDataType.java
  11. 2
      src/main/java/org/mosad/homeflix/datatypes/FilmTabelDataType.java
  12. 2
      src/main/java/org/mosad/homeflix/datatypes/PosterModeElement.java
  13. 2
      src/main/java/org/mosad/homeflix/datatypes/SourceDataType.java
  14. 2
      src/main/java/org/mosad/homeflix/player/HFMediaPlayerEventListener.java
  15. 2
      src/main/java/org/mosad/homeflix/player/Player.java
  16. 94
      src/main/java/org/mosad/homeflix/player/PlayerController.java

4
pom.xml

@ -76,13 +76,13 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.17.0</version>
<version>2.17.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.17.0</version>
<version>2.17.1</version>
</dependency>
</dependencies>

2
src/main/java/org/mosad/homeflix/application/Main.java

@ -1,7 +1,7 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2019 <@Seil0>
* Copyright 2016-2022 <@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

2
src/main/java/org/mosad/homeflix/application/MainWindowController.java

@ -1,7 +1,7 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2019 <@Seil0>
* Copyright 2016-2022 <@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

2
src/main/java/org/mosad/homeflix/application/SettingsView.java

@ -1,7 +1,7 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2019 <@Seil0>
* Copyright 2016-2022 <@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

2
src/main/java/org/mosad/homeflix/application/view/FilmDetailView.java

@ -1,7 +1,7 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2019 <@Seil0>
* Copyright 2016-2022 <@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

2
src/main/java/org/mosad/homeflix/application/view/SeriesDetailView.java

@ -1,7 +1,7 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2019 <@Seil0>
* Copyright 2016-2022 <@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

2
src/main/java/org/mosad/homeflix/controller/DBController.java

@ -1,7 +1,7 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2019 <@Seil0>
* Copyright 2016-2022 <@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

2
src/main/java/org/mosad/homeflix/controller/SourcesController.java

@ -1,7 +1,7 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2019 <@Seil0>
* Copyright 2016-2022 <@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

2
src/main/java/org/mosad/homeflix/controller/XMLController.java

@ -1,7 +1,7 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2019 <@Seil0>
* Copyright 2016-2022 <@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

2
src/main/java/org/mosad/homeflix/datatypes/DatabaseDataType.java

@ -1,7 +1,7 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2019 <@Seil0>
* Copyright 2016-2022 <@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

2
src/main/java/org/mosad/homeflix/datatypes/FilmTabelDataType.java

@ -1,7 +1,7 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2019 <@Seil0>
* Copyright 2016-2022 <@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

2
src/main/java/org/mosad/homeflix/datatypes/PosterModeElement.java

@ -1,7 +1,7 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2019 <@Seil0>
* Copyright 2016-2022 <@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

2
src/main/java/org/mosad/homeflix/datatypes/SourceDataType.java

@ -1,7 +1,7 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2019 <@Seil0>
* Copyright 2016-2022 <@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

2
src/main/java/org/mosad/homeflix/player/HFMediaPlayerEventListener.java

@ -1,7 +1,7 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2020 <seil0@mosad.xyz>
* Copyright 2016-2022 <seil0@mosad.xyz>
*
* 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

2
src/main/java/org/mosad/homeflix/player/Player.java

@ -1,7 +1,7 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2020 <seil0@mosad.xyz>
* Copyright 2016-2022 <seil0@mosad.xyz>
*
* 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

94
src/main/java/org/mosad/homeflix/player/PlayerController.java

@ -1,7 +1,7 @@
/**
* Project-HomeFlix
*
* Copyright 2016-2020 <seil0@mosad.xyz>
* Copyright 2016-2022 <seil0@mosad.xyz>
*
* 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
@ -28,13 +28,13 @@ import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit;
import org.mosad.homeflix.controller.DBController;
import org.mosad.homeflix.controller.XMLController;
import org.mosad.homeflix.datatypes.FilmTabelDataType;
import com.jfoenix.controls.JFXButton;
import com.jfoenix.controls.JFXDialogLayout;
import com.jfoenix.controls.JFXListCell;
import com.jfoenix.controls.JFXListView;
import com.jfoenix.controls.JFXPopup;
import com.jfoenix.controls.JFXPopup.PopupHPosition;
@ -61,6 +61,8 @@ import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.util.StringConverter;
import uk.co.caprica.vlcj.factory.MediaPlayerFactory;
@ -125,8 +127,10 @@ public class PlayerController {
private long endTime = 0;
private long skipTime = 0;
private long duration = 0;
private List<TrackDescription> tracks = new ArrayList<>();
private int currentTrack = 0;
private List<TrackDescription> audioTracks = new ArrayList<>();
private List<TrackDescription> subtitleTracks = new ArrayList<>();
private int currentAudioTrack = 0;
private int currentSubtitleTrack = 0;
private int season = 0;
private int episode = 0;
@ -244,8 +248,10 @@ public class PlayerController {
@Override
public void mediaPlayerReady(MediaPlayer mediaPlayer) {
tracks = mediaPlayer.audio().trackDescriptions();
currentTrack = mediaPlayer.audio().track();
audioTracks = mediaPlayer.audio().trackDescriptions();
subtitleTracks = mediaPlayer.subpictures().trackDescriptions();
currentAudioTrack = mediaPlayer.audio().track();
currentSubtitleTrack = mediaPlayer.subpictures().track();
}
@Override
@ -440,7 +446,8 @@ public class PlayerController {
@FXML
void btnReplayAction(ActionEvent event) {
embeddedMediaPlayer.controls().skipTime(-10000);
// update currentTime, endTime and controls if play back is paused
if (!embeddedMediaPlayer.status().isPlaying()) {
currentTime = currentTime - 10000;
endTime = endTime + 10000;
@ -455,6 +462,7 @@ public class PlayerController {
void btnForwardAction(ActionEvent event) {
embeddedMediaPlayer.controls().skipTime(10000);
// update currentTime, endTime and controls if play back is paused
if (!embeddedMediaPlayer.status().isPlaying()) {
currentTime = currentTime + 10000;
endTime = endTime - 10000;
@ -470,24 +478,53 @@ public class PlayerController {
if (audioPopup == null) {
audioPopup = new JFXPopup();
JFXListView<String> list = new JFXListView<String>();
tracks.forEach(track -> {
list.getItems().add(track.description());
// audio track
JFXListView<TrackDescription> audioList = new JFXListView<>();
audioList.setCellFactory(param -> new TrackDescriptionCellFactory());
audioList.setOnMouseClicked(ev -> {
setAudioTrack(audioList.getSelectionModel().getSelectedItem().id());
audioPopup.hide();
});
audioTracks.forEach(track -> {
audioList.getItems().add(track);
if (track.id() == currentAudioTrack) {
audioList.getSelectionModel().select(track);
}
});
list.getSelectionModel().select(currentTrack);
list.setOnMouseClicked(ev -> {
setAudioTrack(list.getSelectionModel().getSelectedIndex());
Text audioHeading = new Text("Audio");
audioHeading.setFill(Color.WHITE);
audioHeading.setFont(Font.font(null, FontWeight.BOLD, 16));
// subtitle track
JFXListView<TrackDescription> subtitleList = new JFXListView<>();
subtitleList.setCellFactory(param -> new TrackDescriptionCellFactory());
subtitleList.setOnMouseClicked(ev -> {
setSubtitleTrack(subtitleList.getSelectionModel().getSelectedItem().id());
audioPopup.hide();
});
Text heading = new Text("Audio");
heading.setFill(Color.WHITE);
subtitleTracks.forEach(track -> {
subtitleList.getItems().add(track);
if (track.id() == currentSubtitleTrack) {
subtitleList.getSelectionModel().select(track);
}
});
Text subtitleHeading = new Text("Subtitles");
subtitleHeading.setFill(Color.WHITE);
subtitleHeading.setFont(Font.font(null, FontWeight.BOLD, 16));
// build dialog layout
VBox audioBox = new VBox(audioHeading, audioList);
VBox subtileBox = new VBox(subtitleHeading, subtitleList);
HBox hbox = new HBox(audioBox, subtileBox);
JFXDialogLayout content = new JFXDialogLayout();
content.setPrefSize(150, 200);
content.setHeading(heading);
content.setBody(list);
content.setBody(hbox);
content.setPadding(new Insets(-20, -20, -20, -20)); // fix JFXDialogLayout padding
content.setSpacing(-10); // fix JFXDialogLayout spacing
@ -535,7 +572,12 @@ public class PlayerController {
*/
private void setAudioTrack(int track) {
embeddedMediaPlayer.audio().setTrack(track);
currentTrack = track;
currentAudioTrack = track;
}
private void setSubtitleTrack(int track) {
embeddedMediaPlayer.subpictures().setTrack(track);
currentSubtitleTrack = track;
}
public double getCurrentTime() {
@ -576,4 +618,18 @@ public class PlayerController {
Platform.runLater(() -> videoPixelBuffer.updateBuffer(pb -> null));
}
}
private class TrackDescriptionCellFactory extends JFXListCell<TrackDescription> {
@Override
protected void updateItem(TrackDescription item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null || item.description() == null) {
setText(null);
} else {
setText(item.description());
}
}
}
}

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close