add subtitle support to player; update log4j to version 2.17.1
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				ci/woodpecker/push/woodpecker Pipeline was successful
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	ci/woodpecker/push/woodpecker Pipeline was successful
				
			This commit is contained in:
		
							
								
								
									
										4
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										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> | ||||
|  | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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 | ||||
|  | ||||
| @ -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()); | ||||
| 			}); | ||||
| 			 | ||||
| 			list.getSelectionModel().select(currentTrack); | ||||
| 			list.setOnMouseClicked(ev -> { | ||||
| 				setAudioTrack(list.getSelectionModel().getSelectedIndex()); | ||||
| 			// audio track | ||||
| 			JFXListView<TrackDescription> audioList = new JFXListView<>(); | ||||
| 			audioList.setCellFactory(param -> new TrackDescriptionCellFactory()); | ||||
| 			audioList.setOnMouseClicked(ev -> { | ||||
| 				setAudioTrack(audioList.getSelectionModel().getSelectedItem().id()); | ||||
| 				audioPopup.hide(); | ||||
| 			}); | ||||
| 			 | ||||
| 			Text heading = new Text("Audio"); | ||||
| 			heading.setFill(Color.WHITE); | ||||
| 			audioTracks.forEach(track -> { | ||||
| 				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(); | ||||
| 			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()); | ||||
| 	        } | ||||
| 	    } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user