2023年2月18日12:13:24 完善视频路径设置
parent
f521588043
commit
d798ac1665
|
|
@ -163,9 +163,6 @@ public class VideoController {
|
||||||
@FXML
|
@FXML
|
||||||
private AnchorPane video_root;
|
private AnchorPane video_root;
|
||||||
|
|
||||||
@FXML
|
|
||||||
private AnchorPane mv_an;
|
|
||||||
|
|
||||||
public void full_screen() {
|
public void full_screen() {
|
||||||
|
|
||||||
AnchorPane root = null;
|
AnchorPane root = null;
|
||||||
|
|
@ -206,7 +203,9 @@ public class VideoController {
|
||||||
public void onChanged(Change<? extends Media> c) {
|
public void onChanged(Change<? extends Media> c) {
|
||||||
while (c.next()) {
|
while (c.next()) {
|
||||||
if (c.wasAdded()) {
|
if (c.wasAdded()) {
|
||||||
VideoController.this.mp = new MediaPlayer((Media) medias.get(VideoController.this.playindex.get()));
|
if ((medias.size() - 1) >= VideoController.this.playindex.get()) {
|
||||||
|
VideoController.this.mp = new MediaPlayer(medias.get(VideoController.this.playindex.get()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (medias.size() == 0) {
|
if (medias.size() == 0) {
|
||||||
VideoController.this.isplaying.set(false);
|
VideoController.this.isplaying.set(false);
|
||||||
|
|
@ -260,11 +259,11 @@ public class VideoController {
|
||||||
initSt();
|
initSt();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initSt(){
|
public void initSt() {
|
||||||
this.hbox = new HBox(gap);
|
this.hbox = new HBox(gap);
|
||||||
this.hbox.setScaleY(-1.0D);
|
this.hbox.setScaleY(-1.0D);
|
||||||
this.height = FXCollections.observableArrayList();
|
this.height = FXCollections.observableArrayList();
|
||||||
for(int i = 0; i < this.number; ++i) {
|
for (int i = 0; i < this.number; ++i) {
|
||||||
this.height.add(new SimpleFloatProperty(0.0F));
|
this.height.add(new SimpleFloatProperty(0.0F));
|
||||||
Color color = ColorUtils.random_color();
|
Color color = ColorUtils.random_color();
|
||||||
// Color color = Color.DEEPSKYBLUE;
|
// Color color = Color.DEEPSKYBLUE;
|
||||||
|
|
@ -312,12 +311,12 @@ public class VideoController {
|
||||||
if (event.getClickCount() == 1 && event.getButton() == MouseButton.PRIMARY) {
|
if (event.getClickCount() == 1 && event.getButton() == MouseButton.PRIMARY) {
|
||||||
AnchorPane root = null;
|
AnchorPane root = null;
|
||||||
try {
|
try {
|
||||||
root = FXMLLoader.load(ResourcesUtils.getResource("music-set"));
|
root = FXMLLoader.load(ResourcesUtils.getResource("video-set"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Stage primaryStage= (Stage) VideoController.this.listView.getScene().getWindow();
|
Stage primaryStage = (Stage) VideoController.this.listView.getScene().getWindow();
|
||||||
AlertUtils.alert("设置",root,primaryStage);
|
AlertUtils.alert("设置", root, primaryStage);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -342,7 +341,7 @@ public class VideoController {
|
||||||
});
|
});
|
||||||
this.iv_cycle.setOnMouseClicked(event -> {
|
this.iv_cycle.setOnMouseClicked(event -> {
|
||||||
if (event.getButton().equals(MouseButton.PRIMARY)) {
|
if (event.getButton().equals(MouseButton.PRIMARY)) {
|
||||||
log.info("随机播放按钮:{}","cycle_button");
|
log.info("随机播放按钮:{}", "cycle_button");
|
||||||
VideoController.this.cycletype.set((VideoController.this.cycletype.get() + 1) % 3);
|
VideoController.this.cycletype.set((VideoController.this.cycletype.get() + 1) % 3);
|
||||||
VideoController.this.iv_cycle.setImage(ICON_WHITE_RANDOM);
|
VideoController.this.iv_cycle.setImage(ICON_WHITE_RANDOM);
|
||||||
}
|
}
|
||||||
|
|
@ -419,7 +418,7 @@ public class VideoController {
|
||||||
|
|
||||||
this.iv_vol.hoverProperty().addListener(new ChangeListener<Boolean>() {
|
this.iv_vol.hoverProperty().addListener(new ChangeListener<Boolean>() {
|
||||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
||||||
log.info("静音按钮:{}" , newValue);
|
log.info("静音按钮:{}", newValue);
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
if (VideoController.this.iv_vol.getImage().equals(vol_white)) {
|
if (VideoController.this.iv_vol.getImage().equals(vol_white)) {
|
||||||
VideoController.this.iv_vol.setImage(vol_black);
|
VideoController.this.iv_vol.setImage(vol_black);
|
||||||
|
|
@ -439,7 +438,7 @@ public class VideoController {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.iv_vol.setOnMouseClicked(event -> {
|
this.iv_vol.setOnMouseClicked(event -> {
|
||||||
log.info("音量按钮:{}" , event.getButton().name());
|
log.info("音量按钮:{}", event.getButton().name());
|
||||||
if (event.getButton().equals(MouseButton.PRIMARY) && VideoController.this.mp != null) {
|
if (event.getButton().equals(MouseButton.PRIMARY) && VideoController.this.mp != null) {
|
||||||
if (VideoController.this.mp.isMute()) {
|
if (VideoController.this.mp.isMute()) {
|
||||||
VideoController.this.mp.setMute(false);
|
VideoController.this.mp.setMute(false);
|
||||||
|
|
@ -532,7 +531,7 @@ public class VideoController {
|
||||||
this.mp.setVolume(sl_vol_num);
|
this.mp.setVolume(sl_vol_num);
|
||||||
|
|
||||||
this.sl_vol.valueProperty().addListener((observableValue, number, t1) -> {
|
this.sl_vol.valueProperty().addListener((observableValue, number, t1) -> {
|
||||||
log.info("音量调节:{}",t1.doubleValue());
|
log.info("音量调节:{}", t1.doubleValue());
|
||||||
VideoController.this.mp.setVolume(t1.doubleValue() / 100);
|
VideoController.this.mp.setVolume(t1.doubleValue() / 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -562,7 +561,7 @@ public class VideoController {
|
||||||
this.mv.setMediaPlayer(mp);
|
this.mv.setMediaPlayer(mp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initListView(){
|
public void initListView() {
|
||||||
listView.setItems(files);
|
listView.setItems(files);
|
||||||
Text placehold = new Text("列表为空,点击设置添加音乐目录");
|
Text placehold = new Text("列表为空,点击设置添加音乐目录");
|
||||||
placehold.setFill(Color.WHITE);
|
placehold.setFill(Color.WHITE);
|
||||||
|
|
@ -574,7 +573,7 @@ public class VideoController {
|
||||||
list_cell();
|
list_cell();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void list_cell(){
|
private void list_cell() {
|
||||||
listView.setCellFactory(new Callback<ListView<File>, ListCell<File>>() {
|
listView.setCellFactory(new Callback<ListView<File>, ListCell<File>>() {
|
||||||
public ListCell<File> call(ListView<File> param) {
|
public ListCell<File> call(ListView<File> param) {
|
||||||
final ListCell<File> cell = new ListCell<File>() {
|
final ListCell<File> cell = new ListCell<File>() {
|
||||||
|
|
@ -596,7 +595,7 @@ public class VideoController {
|
||||||
this.setAlignment(Pos.CENTER_LEFT);
|
this.setAlignment(Pos.CENTER_LEFT);
|
||||||
this.setGraphic(text);
|
this.setGraphic(text);
|
||||||
this.setOpacity(1.0D);
|
this.setOpacity(1.0D);
|
||||||
this.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, (CornerRadii)null, (Insets)null)));
|
this.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, (CornerRadii) null, (Insets) null)));
|
||||||
} else {
|
} else {
|
||||||
this.setGraphic(null);
|
this.setGraphic(null);
|
||||||
this.setOpacity(0.0D);
|
this.setOpacity(0.0D);
|
||||||
|
|
@ -623,12 +622,12 @@ public class VideoController {
|
||||||
Text text;
|
Text text;
|
||||||
if (newValue.intValue() == cell.getIndex()) {
|
if (newValue.intValue() == cell.getIndex()) {
|
||||||
if (cell.getGraphic() != null) {
|
if (cell.getGraphic() != null) {
|
||||||
text = (Text)cell.getGraphic();
|
text = (Text) cell.getGraphic();
|
||||||
text.setFont(Font.font(16.0D));
|
text.setFont(Font.font(16.0D));
|
||||||
text.setFill(Color.DEEPSKYBLUE);
|
text.setFill(Color.DEEPSKYBLUE);
|
||||||
}
|
}
|
||||||
} else if (cell.getGraphic() != null) {
|
} else if (cell.getGraphic() != null) {
|
||||||
text = (Text)cell.getGraphic();
|
text = (Text) cell.getGraphic();
|
||||||
text.setFont(Font.font(13.0D));
|
text.setFont(Font.font(13.0D));
|
||||||
text.setFill(Color.BLACK);
|
text.setFill(Color.BLACK);
|
||||||
}
|
}
|
||||||
|
|
@ -656,7 +655,7 @@ public class VideoController {
|
||||||
});
|
});
|
||||||
|
|
||||||
progressBar.setOnMouseDragged(event1 -> {
|
progressBar.setOnMouseDragged(event1 -> {
|
||||||
if ( player.getStatus() == MediaPlayer.Status.PLAYING) {
|
if (player.getStatus() == MediaPlayer.Status.PLAYING) {
|
||||||
player.seek(progressBar.getCurrentTime());
|
player.seek(progressBar.getCurrentTime());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -670,21 +669,15 @@ public class VideoController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ObservableList<File> getDirsList() {
|
public static ObservableList<File> getDirsList() {
|
||||||
if (dirs.size() != 0) {
|
String dir = config_path();
|
||||||
return dirs;
|
File file = new File(dir);
|
||||||
} else {
|
if (file.exists() && file.isDirectory()) {
|
||||||
String dir = config_path();
|
dirs.add(file);
|
||||||
// dir = new String(dir.getBytes(), Charset.forName(LRC_CODE));
|
|
||||||
dir = "F:\\B站\\JavaFX视频教程\\1到30课";
|
|
||||||
File file = new File(dir);
|
|
||||||
if (file.exists() && file.isDirectory()) {
|
|
||||||
dirs.add(file);
|
|
||||||
}
|
|
||||||
return dirs;
|
|
||||||
}
|
}
|
||||||
|
return dirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String config_path(){
|
public static String config_path() {
|
||||||
Resource resource = new ClassPathResource("video.properties");
|
Resource resource = new ClassPathResource("video.properties");
|
||||||
InputStream inputStream = resource.getStream();
|
InputStream inputStream = resource.getStream();
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
|
|
@ -733,13 +726,12 @@ public class VideoController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addDir(File file) {
|
public static void addDir(File file) {
|
||||||
dirs.add(file);
|
|
||||||
File[] addfiles = file.listFiles(new FilenameFilter() {
|
File[] addfiles = file.listFiles(new FilenameFilter() {
|
||||||
public boolean accept(File dir, String name) {
|
public boolean accept(File dir, String name) {
|
||||||
return name.endsWith("mp4");
|
return name.endsWith("mp4");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
files.clear();
|
||||||
for (int i = 0; i < addfiles.length; ++i) {
|
for (int i = 0; i < addfiles.length; ++i) {
|
||||||
Media media = new Media(addfiles[i].toURI().toASCIIString());
|
Media media = new Media(addfiles[i].toURI().toASCIIString());
|
||||||
medias.add(media);
|
medias.add(media);
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,8 @@ public class VideoSetController {
|
||||||
@FXML
|
@FXML
|
||||||
private TextField text_file;
|
private TextField text_file;
|
||||||
|
|
||||||
|
private File file;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
public void initialize(){
|
public void initialize(){
|
||||||
log.info("music set ....");
|
log.info("music set ....");
|
||||||
|
|
@ -45,12 +47,13 @@ public class VideoSetController {
|
||||||
Stage stage = (Stage) file_choose_button.getScene().getWindow();
|
Stage stage = (Stage) file_choose_button.getScene().getWindow();
|
||||||
DirectoryChooser dc = new DirectoryChooser();
|
DirectoryChooser dc = new DirectoryChooser();
|
||||||
dc.setTitle("文件夹选择器");
|
dc.setTitle("文件夹选择器");
|
||||||
File file = dc.showDialog(stage);
|
file = dc.showDialog(stage);
|
||||||
if (file != null){
|
if (file != null){
|
||||||
String path = file.getAbsolutePath();
|
String path = file.getAbsolutePath();
|
||||||
text_file.setText(path);
|
text_file.setText(path);
|
||||||
|
}else {
|
||||||
|
AlertUtils.alert_warning("请选择文件夹!");
|
||||||
}
|
}
|
||||||
VideoController.addDir(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
|
|
@ -64,6 +67,11 @@ public class VideoSetController {
|
||||||
//关闭
|
//关闭
|
||||||
Stage stage = (Stage) text_file.getScene().getWindow();
|
Stage stage = (Stage) text_file.getScene().getWindow();
|
||||||
stage.close();
|
stage.close();
|
||||||
|
|
||||||
|
if (file != null){
|
||||||
|
VideoController.addDir(file);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue