add demo audio track selection popup
This commit is contained in:
parent
5e0fd8063d
commit
c04a7c0d4d
14
pom.xml
14
pom.xml
|
@ -27,25 +27,25 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjfx</groupId>
|
<groupId>org.openjfx</groupId>
|
||||||
<artifactId>javafx-controls</artifactId>
|
<artifactId>javafx-controls</artifactId>
|
||||||
<version>14</version>
|
<version>14.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjfx</groupId>
|
<groupId>org.openjfx</groupId>
|
||||||
<artifactId>javafx-fxml</artifactId>
|
<artifactId>javafx-fxml</artifactId>
|
||||||
<version>14</version>
|
<version>14.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openjfx</groupId>
|
<groupId>org.openjfx</groupId>
|
||||||
<artifactId>javafx-media</artifactId>
|
<artifactId>javafx-media</artifactId>
|
||||||
<version>14</version>
|
<version>14.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>uk.co.caprica</groupId>
|
<groupId>uk.co.caprica</groupId>
|
||||||
<artifactId>vlcj</artifactId>
|
<artifactId>vlcj</artifactId>
|
||||||
<version>4.5.1</version>
|
<version>4.5.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -69,19 +69,19 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.xerial</groupId>
|
<groupId>org.xerial</groupId>
|
||||||
<artifactId>sqlite-jdbc</artifactId>
|
<artifactId>sqlite-jdbc</artifactId>
|
||||||
<version>3.30.1</version>
|
<version>3.31.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.logging.log4j</groupId>
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
<artifactId>log4j-api</artifactId>
|
<artifactId>log4j-api</artifactId>
|
||||||
<version>2.13.1</version>
|
<version>2.13.3</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.13.1</version>
|
<version>2.13.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class Main extends Application {
|
||||||
// TODO rename streamURL to mediaURL
|
// TODO rename streamURL to mediaURL
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) throws IOException {
|
public void start(Stage primaryStage) {
|
||||||
|
|
||||||
//initialize the mainWindowController and the primaryStage
|
//initialize the mainWindowController and the primaryStage
|
||||||
try {
|
try {
|
||||||
|
@ -118,7 +118,7 @@ public class Main extends Application {
|
||||||
XMLController.getPosterCache().mkdir();
|
XMLController.getPosterCache().mkdir();
|
||||||
}
|
}
|
||||||
|
|
||||||
launch(args);
|
launch();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class Player {
|
||||||
*/
|
*/
|
||||||
public Player(String streamURL) {
|
public Player(String streamURL) {
|
||||||
try {
|
try {
|
||||||
newHFPlayer(streamURL);
|
defaultPlayer(streamURL);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOGGER.error("Error while playing media", e);
|
LOGGER.error("Error while playing media", e);
|
||||||
legacyPlayer(streamURL);
|
legacyPlayer(streamURL);
|
||||||
|
@ -67,7 +67,7 @@ public class Player {
|
||||||
* start the integrated player
|
* start the integrated player
|
||||||
* @param streamURL
|
* @param streamURL
|
||||||
*/
|
*/
|
||||||
private void newHFPlayer(String mediaURL) {
|
private void defaultPlayer(String mediaURL) {
|
||||||
playerController = new PlayerController(this, mediaURL);
|
playerController = new PlayerController(this, mediaURL);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -32,6 +32,10 @@ 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.JFXPopup;
|
||||||
|
import com.jfoenix.controls.JFXPopup.PopupHPosition;
|
||||||
|
import com.jfoenix.controls.JFXPopup.PopupVPosition;
|
||||||
import com.jfoenix.controls.JFXSlider;
|
import com.jfoenix.controls.JFXSlider;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
|
@ -48,9 +52,11 @@ import javafx.scene.image.PixelBuffer;
|
||||||
import javafx.scene.image.PixelFormat;
|
import javafx.scene.image.PixelFormat;
|
||||||
import javafx.scene.image.WritableImage;
|
import javafx.scene.image.WritableImage;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import javafx.scene.media.MediaView;
|
import javafx.scene.media.MediaView;
|
||||||
|
import javafx.scene.text.Text;
|
||||||
import uk.co.caprica.vlcj.factory.MediaPlayerFactory;
|
import uk.co.caprica.vlcj.factory.MediaPlayerFactory;
|
||||||
import uk.co.caprica.vlcj.player.base.MediaPlayer;
|
import uk.co.caprica.vlcj.player.base.MediaPlayer;
|
||||||
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
|
import uk.co.caprica.vlcj.player.embedded.EmbeddedMediaPlayer;
|
||||||
|
@ -63,6 +69,7 @@ import uk.co.caprica.vlcj.player.embedded.videosurface.callback.format.RV32Buffe
|
||||||
|
|
||||||
public class PlayerController {
|
public class PlayerController {
|
||||||
|
|
||||||
|
@FXML private AnchorPane panePlayer;
|
||||||
@FXML private MediaView mediaView;
|
@FXML private MediaView mediaView;
|
||||||
@FXML private ImageView videoImageView;
|
@FXML private ImageView videoImageView;
|
||||||
|
|
||||||
|
@ -77,8 +84,9 @@ public class PlayerController {
|
||||||
@FXML private JFXButton btnPlay;
|
@FXML private JFXButton btnPlay;
|
||||||
@FXML private JFXButton btnReplay;
|
@FXML private JFXButton btnReplay;
|
||||||
@FXML private JFXButton btnForward;
|
@FXML private JFXButton btnForward;
|
||||||
@FXML private JFXButton fullscreenBtn;
|
@FXML private JFXButton btnAudio;
|
||||||
@FXML private JFXButton nextEpBtn;
|
@FXML private JFXButton btnFullscreen;
|
||||||
|
@FXML private JFXButton btnNextEpisode;
|
||||||
|
|
||||||
@FXML private ImageView stopIcon;
|
@FXML private ImageView stopIcon;
|
||||||
@FXML private ImageView playIcon;
|
@FXML private ImageView playIcon;
|
||||||
|
@ -141,7 +149,7 @@ public class PlayerController {
|
||||||
|
|
||||||
initPlayerWindow();
|
initPlayerWindow();
|
||||||
initMediaPlayer();
|
initMediaPlayer();
|
||||||
initSlider();
|
initTimeSlider();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -184,9 +192,22 @@ public class PlayerController {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initialize the embedded media player
|
||||||
|
*/
|
||||||
private void initMediaPlayer() {
|
private void initMediaPlayer() {
|
||||||
embeddedMediaPlayer.events().addMediaPlayerEventListener( new HFMediaPlayerEventListener() {
|
embeddedMediaPlayer.events().addMediaPlayerEventListener( new HFMediaPlayerEventListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mediaPlayerReady(MediaPlayer mediaPlayer) {
|
||||||
|
System.out.println(mediaPlayer.audio().trackCount());
|
||||||
|
|
||||||
|
mediaPlayer.audio().trackDescriptions().forEach(trackDesc -> {
|
||||||
|
System.out.println(trackDesc.description());
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void timeChanged(MediaPlayer mediaPlayer, long newTime) {
|
public void timeChanged(MediaPlayer mediaPlayer, long newTime) {
|
||||||
currentTime = newTime;
|
currentTime = newTime;
|
||||||
|
@ -211,7 +232,10 @@ public class PlayerController {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initSlider() {
|
/**
|
||||||
|
* initialize the time slider
|
||||||
|
*/
|
||||||
|
private void initTimeSlider() {
|
||||||
// if the mouse on the timeSlider is released, skip to the new position
|
// if the mouse on the timeSlider is released, skip to the new position
|
||||||
timeSlider.setOnMouseReleased(new EventHandler<MouseEvent>() {
|
timeSlider.setOnMouseReleased(new EventHandler<MouseEvent>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -228,7 +252,7 @@ public class PlayerController {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// get the new skip time
|
// on value change, get the new skip time
|
||||||
timeSlider.valueProperty().addListener(new ChangeListener<Number>() {
|
timeSlider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||||
@Override
|
@Override
|
||||||
public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
|
public void changed(ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
|
||||||
|
@ -242,6 +266,10 @@ public class PlayerController {
|
||||||
embeddedMediaPlayer.controls().skipTime((long) startTime); // skipt to the start time
|
embeddedMediaPlayer.controls().skipTime((long) startTime); // skipt to the start time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop and release the media player.
|
||||||
|
* Always call this method to stop the media player.
|
||||||
|
*/
|
||||||
public void stop() {
|
public void stop() {
|
||||||
DBController.getInstance().setCurrentTime(media.getStreamUrl(), embeddedMediaPlayer.status().time());
|
DBController.getInstance().setCurrentTime(media.getStreamUrl(), embeddedMediaPlayer.status().time());
|
||||||
embeddedMediaPlayer.controls().stop();
|
embeddedMediaPlayer.controls().stop();
|
||||||
|
@ -269,16 +297,16 @@ public class PlayerController {
|
||||||
if (endTime < 31000 && episode != 0 && autoplay) {
|
if (endTime < 31000 && episode != 0 && autoplay) {
|
||||||
int countdown = (int) ((endTime / 1000) - 20); // a 10 seconds countdown
|
int countdown = (int) ((endTime / 1000) - 20); // a 10 seconds countdown
|
||||||
|
|
||||||
if (!nextEpBtn.isVisible()) {
|
if (!btnNextEpisode.isVisible()) {
|
||||||
nextEpBtn.setVisible(true);
|
btnNextEpisode.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endTime > 20000) {
|
if (endTime > 20000) {
|
||||||
nextEpBtn.setText(XMLController.getLocalBundle().getString("nextEpisode")
|
btnNextEpisode.setText(XMLController.getLocalBundle().getString("nextEpisode")
|
||||||
+ countdown + XMLController.getLocalBundle().getString("seconds"));
|
+ countdown + XMLController.getLocalBundle().getString("seconds"));
|
||||||
bottomVBox.setVisible(true);
|
bottomVBox.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
nextEpBtn.setVisible(false);
|
btnNextEpisode.setVisible(false);
|
||||||
playNextMedia();
|
playNextMedia();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -312,7 +340,22 @@ public class PlayerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void fullscreenBtnAction(ActionEvent event) {
|
void btnAudioAction(ActionEvent event) {
|
||||||
|
// TODO move to separate class "AudioPopup"
|
||||||
|
|
||||||
|
JFXDialogLayout content = new JFXDialogLayout();
|
||||||
|
content.setHeading(new Text("Test"));
|
||||||
|
content.setBody(new Text("Hallo 123"));
|
||||||
|
content.setPrefSize(150, 200);
|
||||||
|
|
||||||
|
JFXPopup popup = new JFXPopup();
|
||||||
|
popup.setPopupContent(content);
|
||||||
|
popup.show(btnAudio, PopupVPosition.BOTTOM, PopupHPosition.RIGHT,
|
||||||
|
0, -1 * bottomVBox.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
void btnFullscreenAction(ActionEvent event) {
|
||||||
if (player.getStage().isFullScreen()) {
|
if (player.getStage().isFullScreen()) {
|
||||||
player.getStage().setFullScreen(false);
|
player.getStage().setFullScreen(false);
|
||||||
fullscreenIcon.setImage(fullscreen);
|
fullscreenIcon.setImage(fullscreen);
|
||||||
|
@ -323,8 +366,8 @@ public class PlayerController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
void nextEpBtnAction(ActionEvent event) {
|
void btnNextEpisodeAction(ActionEvent event) {
|
||||||
nextEpBtn.setVisible(false);
|
btnNextEpisode.setVisible(false);
|
||||||
playNextMedia();
|
playNextMedia();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<?import javafx.scene.media.MediaView?>
|
<?import javafx.scene.media.MediaView?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<AnchorPane prefHeight="720.0" prefWidth="1280.0" style="-fx-background-color: black;" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
<AnchorPane fx:id="panePlayer" prefHeight="720.0" prefWidth="1280.0" style="-fx-background-color: black;" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
|
||||||
<children>
|
<children>
|
||||||
<HBox alignment="CENTER" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
<HBox alignment="CENTER" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
|
||||||
<children>
|
<children>
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
<children>
|
<children>
|
||||||
<HBox spacing="10.0">
|
<HBox spacing="10.0">
|
||||||
<children>
|
<children>
|
||||||
<JFXButton fx:id="btnPlay" buttonType="RAISED" contentDisplay="GRAPHIC_ONLY" onAction="#btnPlayAction">
|
<JFXButton fx:id="btnPlay" contentDisplay="GRAPHIC_ONLY" onAction="#btnPlayAction">
|
||||||
<graphic>
|
<graphic>
|
||||||
<ImageView fx:id="playIcon" fitHeight="42.0" pickOnBounds="true" preserveRatio="true">
|
<ImageView fx:id="playIcon" fitHeight="42.0" pickOnBounds="true" preserveRatio="true">
|
||||||
<image>
|
<image>
|
||||||
|
@ -97,9 +97,18 @@
|
||||||
<Insets left="5.0" right="5.0" />
|
<Insets left="5.0" right="5.0" />
|
||||||
</padding>
|
</padding>
|
||||||
</HBox>
|
</HBox>
|
||||||
<HBox alignment="TOP_RIGHT" HBox.hgrow="ALWAYS">
|
<HBox alignment="TOP_RIGHT" spacing="10.0" HBox.hgrow="ALWAYS">
|
||||||
<children>
|
<children>
|
||||||
<JFXButton fx:id="fullscreenBtn" buttonType="RAISED" contentDisplay="GRAPHIC_ONLY" onAction="#fullscreenBtnAction" prefHeight="39.0">
|
<JFXButton fx:id="btnAudio" contentDisplay="GRAPHIC_ONLY" onAction="#btnAudioAction">
|
||||||
|
<graphic>
|
||||||
|
<ImageView fitHeight="42.0" pickOnBounds="true" preserveRatio="true">
|
||||||
|
<image>
|
||||||
|
<Image url="@../icons/baseline_subtitles_white_48dp.png" />
|
||||||
|
</image>
|
||||||
|
</ImageView>
|
||||||
|
</graphic>
|
||||||
|
</JFXButton>
|
||||||
|
<JFXButton fx:id="btnFullscreen" contentDisplay="GRAPHIC_ONLY" onAction="#btnFullscreenAction" prefHeight="39.0">
|
||||||
<graphic>
|
<graphic>
|
||||||
<ImageView fx:id="fullscreenIcon" fitHeight="42.0" pickOnBounds="true" preserveRatio="true">
|
<ImageView fx:id="fullscreenIcon" fitHeight="42.0" pickOnBounds="true" preserveRatio="true">
|
||||||
<image>
|
<image>
|
||||||
|
@ -123,7 +132,7 @@
|
||||||
<Insets bottom="5.0" />
|
<Insets bottom="5.0" />
|
||||||
</padding>
|
</padding>
|
||||||
</VBox>
|
</VBox>
|
||||||
<JFXButton fx:id="nextEpBtn" onAction="#nextEpBtnAction" style="-fx-background-color: ee3523;" text="next episode in 10 seconds" textFill="WHITE" visible="false" AnchorPane.bottomAnchor="100.0" AnchorPane.rightAnchor="20.0">
|
<JFXButton fx:id="btnNextEpisode" onAction="#btnNextEpisodeAction" style="-fx-background-color: ee3523;" text="next episode in 10 seconds" textFill="WHITE" visible="false" AnchorPane.bottomAnchor="100.0" AnchorPane.rightAnchor="20.0">
|
||||||
<font>
|
<font>
|
||||||
<Font name="System Bold" size="14.0" />
|
<Font name="System Bold" size="14.0" />
|
||||||
</font>
|
</font>
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 200 B |
Loading…
Reference in New Issue