add subtitle support to player; update log4j to version 2.17.1
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
parent
ce49804c87
commit
d167b60661
4
pom.xml
4
pom.xml
|
@ -76,13 +76,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-api</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
<version>2.17.0</version>
|
<version>2.17.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-core</artifactId>
|
<artifactId>log4j-core</artifactId>
|
||||||
<version>2.17.0</version>
|
<version>2.17.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* Project-HomeFlix
|
||||||
*
|
*
|
||||||
* Copyright 2016-2019 <@Seil0>
|
* Copyright 2016-2022 <@Seil0>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* Project-HomeFlix
|
||||||
*
|
*
|
||||||
* Copyright 2016-2019 <@Seil0>
|
* Copyright 2016-2022 <@Seil0>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* Project-HomeFlix
|
||||||
*
|
*
|
||||||
* Copyright 2016-2019 <@Seil0>
|
* Copyright 2016-2022 <@Seil0>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* Project-HomeFlix
|
||||||
*
|
*
|
||||||
* Copyright 2016-2019 <@Seil0>
|
* Copyright 2016-2022 <@Seil0>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* Project-HomeFlix
|
||||||
*
|
*
|
||||||
* Copyright 2016-2019 <@Seil0>
|
* Copyright 2016-2022 <@Seil0>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* Project-HomeFlix
|
||||||
*
|
*
|
||||||
* Copyright 2016-2019 <@Seil0>
|
* Copyright 2016-2022 <@Seil0>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* Project-HomeFlix
|
||||||
*
|
*
|
||||||
* Copyright 2016-2019 <@Seil0>
|
* Copyright 2016-2022 <@Seil0>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* Project-HomeFlix
|
||||||
*
|
*
|
||||||
* Copyright 2016-2019 <@Seil0>
|
* Copyright 2016-2022 <@Seil0>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* Project-HomeFlix
|
||||||
*
|
*
|
||||||
* Copyright 2016-2019 <@Seil0>
|
* Copyright 2016-2022 <@Seil0>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* Project-HomeFlix
|
||||||
*
|
*
|
||||||
* Copyright 2016-2019 <@Seil0>
|
* Copyright 2016-2022 <@Seil0>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* Project-HomeFlix
|
||||||
*
|
*
|
||||||
* Copyright 2016-2019 <@Seil0>
|
* Copyright 2016-2022 <@Seil0>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* Project-HomeFlix
|
||||||
*
|
*
|
||||||
* Copyright 2016-2019 <@Seil0>
|
* Copyright 2016-2022 <@Seil0>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* 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
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Project-HomeFlix
|
* 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
|
* 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
|
* 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.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.mosad.homeflix.controller.DBController;
|
import org.mosad.homeflix.controller.DBController;
|
||||||
import org.mosad.homeflix.controller.XMLController;
|
import org.mosad.homeflix.controller.XMLController;
|
||||||
import org.mosad.homeflix.datatypes.FilmTabelDataType;
|
import org.mosad.homeflix.datatypes.FilmTabelDataType;
|
||||||
|
|
||||||
import com.jfoenix.controls.JFXButton;
|
import com.jfoenix.controls.JFXButton;
|
||||||
import com.jfoenix.controls.JFXDialogLayout;
|
import com.jfoenix.controls.JFXDialogLayout;
|
||||||
|
import com.jfoenix.controls.JFXListCell;
|
||||||
import com.jfoenix.controls.JFXListView;
|
import com.jfoenix.controls.JFXListView;
|
||||||
import com.jfoenix.controls.JFXPopup;
|
import com.jfoenix.controls.JFXPopup;
|
||||||
import com.jfoenix.controls.JFXPopup.PopupHPosition;
|
import com.jfoenix.controls.JFXPopup.PopupHPosition;
|
||||||
|
@ -61,6 +61,8 @@ import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.scene.text.Font;
|
||||||
|
import javafx.scene.text.FontWeight;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import javafx.util.StringConverter;
|
import javafx.util.StringConverter;
|
||||||
import uk.co.caprica.vlcj.factory.MediaPlayerFactory;
|
import uk.co.caprica.vlcj.factory.MediaPlayerFactory;
|
||||||
|
@ -125,8 +127,10 @@ public class PlayerController {
|
||||||
private long endTime = 0;
|
private long endTime = 0;
|
||||||
private long skipTime = 0;
|
private long skipTime = 0;
|
||||||
private long duration = 0;
|
private long duration = 0;
|
||||||
private List<TrackDescription> tracks = new ArrayList<>();
|
private List<TrackDescription> audioTracks = new ArrayList<>();
|
||||||
private int currentTrack = 0;
|
private List<TrackDescription> subtitleTracks = new ArrayList<>();
|
||||||
|
private int currentAudioTrack = 0;
|
||||||
|
private int currentSubtitleTrack = 0;
|
||||||
|
|
||||||
private int season = 0;
|
private int season = 0;
|
||||||
private int episode = 0;
|
private int episode = 0;
|
||||||
|
@ -244,8 +248,10 @@ public class PlayerController {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mediaPlayerReady(MediaPlayer mediaPlayer) {
|
public void mediaPlayerReady(MediaPlayer mediaPlayer) {
|
||||||
tracks = mediaPlayer.audio().trackDescriptions();
|
audioTracks = mediaPlayer.audio().trackDescriptions();
|
||||||
currentTrack = mediaPlayer.audio().track();
|
subtitleTracks = mediaPlayer.subpictures().trackDescriptions();
|
||||||
|
currentAudioTrack = mediaPlayer.audio().track();
|
||||||
|
currentSubtitleTrack = mediaPlayer.subpictures().track();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -440,7 +446,8 @@ public class PlayerController {
|
||||||
@FXML
|
@FXML
|
||||||
void btnReplayAction(ActionEvent event) {
|
void btnReplayAction(ActionEvent event) {
|
||||||
embeddedMediaPlayer.controls().skipTime(-10000);
|
embeddedMediaPlayer.controls().skipTime(-10000);
|
||||||
|
|
||||||
|
// update currentTime, endTime and controls if play back is paused
|
||||||
if (!embeddedMediaPlayer.status().isPlaying()) {
|
if (!embeddedMediaPlayer.status().isPlaying()) {
|
||||||
currentTime = currentTime - 10000;
|
currentTime = currentTime - 10000;
|
||||||
endTime = endTime + 10000;
|
endTime = endTime + 10000;
|
||||||
|
@ -455,6 +462,7 @@ public class PlayerController {
|
||||||
void btnForwardAction(ActionEvent event) {
|
void btnForwardAction(ActionEvent event) {
|
||||||
embeddedMediaPlayer.controls().skipTime(10000);
|
embeddedMediaPlayer.controls().skipTime(10000);
|
||||||
|
|
||||||
|
// update currentTime, endTime and controls if play back is paused
|
||||||
if (!embeddedMediaPlayer.status().isPlaying()) {
|
if (!embeddedMediaPlayer.status().isPlaying()) {
|
||||||
currentTime = currentTime + 10000;
|
currentTime = currentTime + 10000;
|
||||||
endTime = endTime - 10000;
|
endTime = endTime - 10000;
|
||||||
|
@ -470,24 +478,53 @@ public class PlayerController {
|
||||||
if (audioPopup == null) {
|
if (audioPopup == null) {
|
||||||
audioPopup = new JFXPopup();
|
audioPopup = new JFXPopup();
|
||||||
|
|
||||||
JFXListView<String> list = new JFXListView<String>();
|
// audio track
|
||||||
tracks.forEach(track -> {
|
JFXListView<TrackDescription> audioList = new JFXListView<>();
|
||||||
list.getItems().add(track.description());
|
audioList.setCellFactory(param -> new TrackDescriptionCellFactory());
|
||||||
});
|
audioList.setOnMouseClicked(ev -> {
|
||||||
|
setAudioTrack(audioList.getSelectionModel().getSelectedItem().id());
|
||||||
list.getSelectionModel().select(currentTrack);
|
|
||||||
list.setOnMouseClicked(ev -> {
|
|
||||||
setAudioTrack(list.getSelectionModel().getSelectedIndex());
|
|
||||||
audioPopup.hide();
|
audioPopup.hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
Text heading = new Text("Audio");
|
audioTracks.forEach(track -> {
|
||||||
heading.setFill(Color.WHITE);
|
audioList.getItems().add(track);
|
||||||
|
if (track.id() == currentAudioTrack) {
|
||||||
|
audioList.getSelectionModel().select(track);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
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();
|
||||||
|
});
|
||||||
|
|
||||||
|
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();
|
JFXDialogLayout content = new JFXDialogLayout();
|
||||||
content.setPrefSize(150, 200);
|
content.setBody(hbox);
|
||||||
content.setHeading(heading);
|
|
||||||
content.setBody(list);
|
|
||||||
content.setPadding(new Insets(-20, -20, -20, -20)); // fix JFXDialogLayout padding
|
content.setPadding(new Insets(-20, -20, -20, -20)); // fix JFXDialogLayout padding
|
||||||
content.setSpacing(-10); // fix JFXDialogLayout spacing
|
content.setSpacing(-10); // fix JFXDialogLayout spacing
|
||||||
|
|
||||||
|
@ -535,7 +572,12 @@ public class PlayerController {
|
||||||
*/
|
*/
|
||||||
private void setAudioTrack(int track) {
|
private void setAudioTrack(int track) {
|
||||||
embeddedMediaPlayer.audio().setTrack(track);
|
embeddedMediaPlayer.audio().setTrack(track);
|
||||||
currentTrack = track;
|
currentAudioTrack = track;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setSubtitleTrack(int track) {
|
||||||
|
embeddedMediaPlayer.subpictures().setTrack(track);
|
||||||
|
currentSubtitleTrack = track;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getCurrentTime() {
|
public double getCurrentTime() {
|
||||||
|
@ -576,4 +618,18 @@ public class PlayerController {
|
||||||
Platform.runLater(() -> videoPixelBuffer.updateBuffer(pb -> null));
|
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…
Reference in New Issue