2023年2月17日14:19:28 修改播放器
parent
d8696608e0
commit
2c23f908cc
|
|
@ -1,5 +1,6 @@
|
||||||
package com.zhangmeng.tools.controller;
|
package com.zhangmeng.tools.controller;
|
||||||
|
|
||||||
|
import com.zhangmeng.tools.utils.AlertUtils;
|
||||||
import com.zhangmeng.tools.utils.EncryptUtils;
|
import com.zhangmeng.tools.utils.EncryptUtils;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
|
|
@ -29,19 +30,11 @@ public class Md5Controller {
|
||||||
button.setOnAction(event -> {
|
button.setOnAction(event -> {
|
||||||
String text = text_filed.getText();
|
String text = text_filed.getText();
|
||||||
if (text.length() == 0) {
|
if (text.length() == 0) {
|
||||||
alert();
|
AlertUtils.alert_warning("请输入将要加密的字符!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
md5_32.setText(EncryptUtils.md5(text));
|
md5_32.setText(EncryptUtils.md5(text));
|
||||||
md5_16.setText(EncryptUtils.md5_16(text));
|
md5_16.setText(EncryptUtils.md5_16(text));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void alert() {
|
|
||||||
Alert alert = new Alert(Alert.AlertType.WARNING);
|
|
||||||
alert.initModality(Modality.APPLICATION_MODAL);
|
|
||||||
alert.setContentText("请输入将要加密的字符!");
|
|
||||||
alert.setHeaderText(null);
|
|
||||||
alert.show();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,10 @@
|
||||||
package com.zhangmeng.tools.controller;
|
package com.zhangmeng.tools.controller;
|
||||||
|
|
||||||
import com.leewyatt.rxcontrols.controls.RXAudioSpectrum;
|
import cn.hutool.core.io.resource.ClassPathResource;
|
||||||
|
import cn.hutool.core.io.resource.Resource;
|
||||||
import com.leewyatt.rxcontrols.controls.RXLrcView;
|
import com.leewyatt.rxcontrols.controls.RXLrcView;
|
||||||
import com.leewyatt.rxcontrols.controls.RXMediaProgressBar;
|
import com.leewyatt.rxcontrols.controls.RXMediaProgressBar;
|
||||||
import com.leewyatt.rxcontrols.pojo.LrcDoc;
|
import com.leewyatt.rxcontrols.pojo.LrcDoc;
|
||||||
import com.leewyatt.rxcontrols.utils.RXResources;
|
|
||||||
import com.leewyatt.rxcontrols.utils.StyleUtil;
|
|
||||||
import com.zhangmeng.tools.utils.*;
|
import com.zhangmeng.tools.utils.*;
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
import javafx.beans.property.SimpleDoubleProperty;
|
import javafx.beans.property.SimpleDoubleProperty;
|
||||||
|
|
@ -18,40 +17,39 @@ import javafx.collections.ListChangeListener;
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.event.EventHandler;
|
import javafx.event.EventHandler;
|
||||||
|
import javafx.event.EventType;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.geometry.Insets;
|
import javafx.geometry.Insets;
|
||||||
import javafx.geometry.Pos;
|
import javafx.geometry.Pos;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.effect.BoxBlur;
|
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
import javafx.scene.input.MouseButton;
|
import javafx.scene.input.MouseButton;
|
||||||
import javafx.scene.input.MouseEvent;
|
import javafx.scene.input.MouseEvent;
|
||||||
import javafx.scene.layout.Background;
|
import javafx.scene.layout.*;
|
||||||
import javafx.scene.layout.BackgroundFill;
|
|
||||||
import javafx.scene.layout.CornerRadii;
|
|
||||||
import javafx.scene.layout.HBox;
|
|
||||||
import javafx.scene.media.AudioSpectrumListener;
|
import javafx.scene.media.AudioSpectrumListener;
|
||||||
import javafx.scene.media.Media;
|
import javafx.scene.media.Media;
|
||||||
import javafx.scene.media.MediaPlayer;
|
import javafx.scene.media.MediaPlayer;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.shape.Polygon;
|
|
||||||
import javafx.scene.shape.Rectangle;
|
import javafx.scene.shape.Rectangle;
|
||||||
import javafx.scene.shape.Shape;
|
|
||||||
import javafx.scene.text.Font;
|
import javafx.scene.text.Font;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import javafx.scene.text.TextAlignment;
|
import javafx.scene.text.TextAlignment;
|
||||||
import javafx.stage.FileChooser;
|
import javafx.stage.Stage;
|
||||||
import javafx.stage.Window;
|
import javafx.stage.Window;
|
||||||
import javafx.util.Callback;
|
import javafx.util.Callback;
|
||||||
import javafx.util.Duration;
|
import javafx.util.Duration;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
import java.util.Properties;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
|
|
@ -60,6 +58,7 @@ import java.util.ResourceBundle;
|
||||||
* @version : 1.0
|
* @version : 1.0
|
||||||
* @date : 2023-02-16 11:09
|
* @date : 2023-02-16 11:09
|
||||||
*/
|
*/
|
||||||
|
@Slf4j
|
||||||
public class MusicController {
|
public class MusicController {
|
||||||
|
|
||||||
private static ObservableList<File> dirs = FXCollections.observableArrayList();
|
private static ObservableList<File> dirs = FXCollections.observableArrayList();
|
||||||
|
|
@ -81,6 +80,8 @@ public class MusicController {
|
||||||
private ObservableList<SimpleFloatProperty> height;
|
private ObservableList<SimpleFloatProperty> height;
|
||||||
private final double width = SpectrumUtils.CELL_WIDTH;
|
private final double width = SpectrumUtils.CELL_WIDTH;
|
||||||
|
|
||||||
|
private double sl_vol_num = 0.30;
|
||||||
|
|
||||||
public ObservableList<SimpleFloatProperty> getHeight() {
|
public ObservableList<SimpleFloatProperty> getHeight() {
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
@ -148,11 +149,6 @@ public class MusicController {
|
||||||
*/
|
*/
|
||||||
private final SimpleIntegerProperty cycletype = new SimpleIntegerProperty(0);
|
private final SimpleIntegerProperty cycletype = new SimpleIntegerProperty(0);
|
||||||
|
|
||||||
/**
|
|
||||||
* 光谱显示
|
|
||||||
*/
|
|
||||||
private HBox spectrum;
|
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private ListView listView;
|
private ListView listView;
|
||||||
|
|
||||||
|
|
@ -192,18 +188,15 @@ public class MusicController {
|
||||||
this.mp = null;
|
this.mp = null;
|
||||||
this.sb = new StringBuffer("");
|
this.sb = new StringBuffer("");
|
||||||
} else {
|
} else {
|
||||||
this.mp = new MediaPlayer((Media) medias.get(this.playindex.get()));
|
this.mp = new MediaPlayer(medias.get(this.playindex.get()));
|
||||||
//加载歌词
|
//加载歌词
|
||||||
load_lyric();
|
load_lyric();
|
||||||
this.sb = new StringBuffer(((File) files.get(this.playindex.get())).getName());
|
this.sb = new StringBuffer(files.get(this.playindex.get()).getName());
|
||||||
this.sb = new StringBuffer(this.sb.substring(0, this.sb.length() - 4));
|
this.sb = new StringBuffer(this.sb.substring(0, this.sb.length() - 4));
|
||||||
|
this.mp.setVolume(sl_vol_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.playindex.addListener(new ChangeListener<Number>() {
|
this.playindex.addListener((observable, oldValue, newValue) -> MusicController.this.myPlay());
|
||||||
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
|
|
||||||
MusicController.this.myPlay();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//设置按钮
|
//设置按钮
|
||||||
set_button();
|
set_button();
|
||||||
|
|
@ -253,15 +246,13 @@ public class MusicController {
|
||||||
Image list_black = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_BLACK_LIST));
|
Image list_black = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_BLACK_LIST));
|
||||||
|
|
||||||
this.iv_list = new ImageView(list_white);
|
this.iv_list = new ImageView(list_white);
|
||||||
this.iv_list.hoverProperty().addListener(new ChangeListener<Boolean>() {
|
this.iv_list.hoverProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
if (newValue) {
|
||||||
if (newValue) {
|
MusicController.this.iv_list.setImage(list_black);
|
||||||
MusicController.this.iv_list.setImage(list_black);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!newValue) {
|
if (!newValue) {
|
||||||
MusicController.this.iv_list.setImage(list_white);
|
MusicController.this.iv_list.setImage(list_white);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -273,19 +264,30 @@ public class MusicController {
|
||||||
Image set_white = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_WHITE_SET));
|
Image set_white = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_WHITE_SET));
|
||||||
Image set_black = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_BLACK_SET));
|
Image set_black = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_BLACK_SET));
|
||||||
|
|
||||||
this.iv_set = new ImageView(set_white);
|
this.iv_set.hoverProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
this.iv_set.hoverProperty().addListener(new ChangeListener<Boolean>() {
|
if (newValue) {
|
||||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
MusicController.this.iv_set.setImage(set_black);
|
||||||
if (newValue) {
|
}
|
||||||
MusicController.this.iv_set.setImage(set_black);
|
if (!newValue) {
|
||||||
}
|
MusicController.this.iv_set.setImage(set_white);
|
||||||
if (!newValue) {
|
}
|
||||||
MusicController.this.iv_set.setImage(set_white);
|
});
|
||||||
|
|
||||||
|
this.iv_set.setOnMouseClicked(event -> {
|
||||||
|
if (event.getClickCount() == 1 && event.getButton() == MouseButton.PRIMARY) {
|
||||||
|
AnchorPane root = null;
|
||||||
|
try {
|
||||||
|
root = FXMLLoader.load(ResourcesUtils.getResource("music-set"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
Stage primaryStage= (Stage) MusicController.this.listView.getScene().getWindow();
|
||||||
|
AlertUtils.alert("设置",root,primaryStage);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 播放器底部 重复按钮
|
* 播放器底部 重复按钮
|
||||||
*/
|
*/
|
||||||
|
|
@ -293,24 +295,21 @@ public class MusicController {
|
||||||
|
|
||||||
Image cycle_icon_white = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_WHITE_REPEAT));
|
Image cycle_icon_white = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_WHITE_REPEAT));
|
||||||
Image cycle_icon_black = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_BLACK_REPEAT));
|
Image cycle_icon_black = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_BLACK_REPEAT));
|
||||||
|
Image ICON_WHITE_RANDOM = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_WHITE_RANDOM));
|
||||||
|
|
||||||
this.iv_cycle = new ImageView(cycle_icon_white);
|
this.iv_cycle.hoverProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
this.iv_cycle.hoverProperty().addListener(new ChangeListener<Boolean>() {
|
if (newValue) {
|
||||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
MusicController.this.iv_cycle.setImage(cycle_icon_black);
|
||||||
if (newValue) {
|
}
|
||||||
MusicController.this.iv_cycle.setImage(cycle_icon_black);
|
if (!newValue) {
|
||||||
}
|
MusicController.this.iv_cycle.setImage(cycle_icon_white);
|
||||||
if (!newValue) {
|
|
||||||
MusicController.this.iv_cycle.setImage(cycle_icon_white);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.iv_cycle.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
this.iv_cycle.setOnMouseClicked(event -> {
|
||||||
public void handle(MouseEvent event) {
|
if (event.getButton().equals(MouseButton.PRIMARY)) {
|
||||||
if (event.getButton().equals(MouseButton.PRIMARY)) {
|
log.info("随机播放按钮:{}","cycle_button");
|
||||||
MusicController.this.cycletype.set((MusicController.this.cycletype.get() + 1) % 3);
|
MusicController.this.cycletype.set((MusicController.this.cycletype.get() + 1) % 3);
|
||||||
MusicController.this.iv_cycle.setImage(cycle_icon_black);
|
MusicController.this.iv_cycle.setImage(ICON_WHITE_RANDOM);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -323,7 +322,6 @@ public class MusicController {
|
||||||
Image last_white = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_WHITE_LAST));
|
Image last_white = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_WHITE_LAST));
|
||||||
Image last_black = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_BLACK_LAST));
|
Image last_black = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_BLACK_LAST));
|
||||||
|
|
||||||
this.iv_last = new ImageView(last_white);
|
|
||||||
this.iv_last.hoverProperty().addListener(new ChangeListener<Boolean>() {
|
this.iv_last.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) {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
|
|
@ -334,11 +332,9 @@ public class MusicController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.iv_last.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
this.iv_last.setOnMouseClicked(event -> {
|
||||||
public void handle(MouseEvent event) {
|
if (event.getButton().equals(MouseButton.PRIMARY) && MusicController.this.mp != null) {
|
||||||
if (event.getButton().equals(MouseButton.PRIMARY) && MusicController.this.mp != null) {
|
MusicController.this.playindex.set((MusicController.this.playindex.get() - 1 + medias.size()) % medias.size());
|
||||||
MusicController.this.playindex.set((MusicController.this.playindex.get() - 1 + medias.size()) % medias.size());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -351,7 +347,6 @@ public class MusicController {
|
||||||
Image next_white = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_WHITE_NEXT));
|
Image next_white = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_WHITE_NEXT));
|
||||||
Image next_black = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_BLACK_NEXT));
|
Image next_black = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_BLACK_NEXT));
|
||||||
|
|
||||||
this.iv_next = new ImageView(next_white);
|
|
||||||
this.iv_next.hoverProperty().addListener(new ChangeListener<Boolean>() {
|
this.iv_next.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) {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
|
|
@ -366,7 +361,7 @@ public class MusicController {
|
||||||
public void handle(MouseEvent event) {
|
public void handle(MouseEvent event) {
|
||||||
if (event.getButton().equals(MouseButton.PRIMARY) && MusicController.this.mp != null) {
|
if (event.getButton().equals(MouseButton.PRIMARY) && MusicController.this.mp != null) {
|
||||||
if (MusicController.this.cycletype.get() == 0 || MusicController.this.cycletype.get() == 1) {
|
if (MusicController.this.cycletype.get() == 0 || MusicController.this.cycletype.get() == 1) {
|
||||||
MusicController.this.playindex.set((MusicController.this.playindex.get() + 1) % MusicController.this.medias.size());
|
MusicController.this.playindex.set((MusicController.this.playindex.get() + 1) % medias.size());
|
||||||
}
|
}
|
||||||
if (MusicController.this.cycletype.get() == 2) {
|
if (MusicController.this.cycletype.get() == 2) {
|
||||||
MusicController.this.playindex.set(MusicController.this.ran.nextInt(MusicController.this.medias.size()));
|
MusicController.this.playindex.set(MusicController.this.ran.nextInt(MusicController.this.medias.size()));
|
||||||
|
|
@ -387,9 +382,9 @@ public class MusicController {
|
||||||
Image mute_white = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_WHITE_MUTE));
|
Image mute_white = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_WHITE_MUTE));
|
||||||
Image mute_black = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_BLACK_MUTE));
|
Image mute_black = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_BLACK_MUTE));
|
||||||
|
|
||||||
this.iv_vol = new ImageView(vol_white);
|
|
||||||
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);
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
if (MusicController.this.iv_vol.getImage().equals(vol_white)) {
|
if (MusicController.this.iv_vol.getImage().equals(vol_white)) {
|
||||||
MusicController.this.iv_vol.setImage(vol_black);
|
MusicController.this.iv_vol.setImage(vol_black);
|
||||||
|
|
@ -408,16 +403,15 @@ public class MusicController {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.iv_vol.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
this.iv_vol.setOnMouseClicked(event -> {
|
||||||
public void handle(MouseEvent event) {
|
log.info("音量按钮:{}" , event.getButton().name());
|
||||||
if (event.getButton().equals(MouseButton.PRIMARY) && MusicController.this.mp != null) {
|
if (event.getButton().equals(MouseButton.PRIMARY) && MusicController.this.mp != null) {
|
||||||
if (MusicController.this.mp.isMute()) {
|
if (MusicController.this.mp.isMute()) {
|
||||||
MusicController.this.mp.setMute(false);
|
MusicController.this.mp.setMute(false);
|
||||||
MusicController.this.iv_vol.setImage(vol_black);
|
MusicController.this.iv_vol.setImage(vol_black);
|
||||||
} else {
|
} else {
|
||||||
MusicController.this.mp.setMute(true);
|
MusicController.this.mp.setMute(true);
|
||||||
MusicController.this.iv_vol.setImage(mute_black);
|
MusicController.this.iv_vol.setImage(mute_black);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -427,8 +421,8 @@ public class MusicController {
|
||||||
* 音量刻度
|
* 音量刻度
|
||||||
*/
|
*/
|
||||||
public void sl_vol_button() {
|
public void sl_vol_button() {
|
||||||
this.sl_vol = new Slider(0.0D, 1.0D, 0.1D);
|
|
||||||
this.sl_vol.setPrefWidth(100.0D);
|
this.sl_vol.setPrefWidth(100.0D);
|
||||||
|
this.sl_vol.setValue(sl_vol_num);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -443,104 +437,92 @@ public class MusicController {
|
||||||
Image pause_white = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_WHITE_PAUSE));
|
Image pause_white = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_WHITE_PAUSE));
|
||||||
Image pause_black = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_BLACK_PAUSE));
|
Image pause_black = new Image(ImagePath.path(ImagePath.ImagePathType.ICON_BLACK_PAUSE));
|
||||||
|
|
||||||
this.iv_play.hoverProperty().addListener(new ChangeListener<Boolean>() {
|
this.iv_play.hoverProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
if (newValue) {
|
||||||
if (newValue) {
|
if (MusicController.this.isplaying.get()) {
|
||||||
if (MusicController.this.isplaying.get()) {
|
|
||||||
MusicController.this.iv_play.setImage(pause_black);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!MusicController.this.isplaying.get()) {
|
|
||||||
MusicController.this.iv_play.setImage(play_black);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!newValue) {
|
|
||||||
if (MusicController.this.isplaying.get()) {
|
|
||||||
MusicController.this.iv_play.setImage(pause_white);
|
|
||||||
}
|
|
||||||
if (!MusicController.this.isplaying.get()) {
|
|
||||||
MusicController.this.iv_play.setImage(play_white);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.iv_play.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
|
||||||
public void handle(MouseEvent event) {
|
|
||||||
|
|
||||||
System.out.println(6666);
|
|
||||||
|
|
||||||
if (event.getButton().equals(MouseButton.PRIMARY) && MusicController.this.mp != null) {
|
|
||||||
MusicController.this.isplaying.set(!MusicController.this.isplaying.get());
|
|
||||||
if (MusicController.this.isplaying.get()) {
|
|
||||||
MusicController.this.iv_play.setImage(pause_white);
|
|
||||||
} else {
|
|
||||||
MusicController.this.iv_play.setImage(play_white);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.isplaying.addListener(new ChangeListener<Boolean>() {
|
|
||||||
public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
|
|
||||||
if (newValue) {
|
|
||||||
MusicController.this.iv_play.setImage(pause_white);
|
|
||||||
if (MusicController.this.mp.getStatus().equals(MediaPlayer.Status.PAUSED)) {
|
|
||||||
MusicController.this.mp.play();
|
|
||||||
} else {
|
|
||||||
MusicController.this.myPlay();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!newValue) {
|
|
||||||
MusicController.this.iv_play.setImage(pause_black);
|
MusicController.this.iv_play.setImage(pause_black);
|
||||||
MusicController.this.mp.pause();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!MusicController.this.isplaying.get()) {
|
||||||
|
MusicController.this.iv_play.setImage(play_black);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!newValue) {
|
||||||
|
if (MusicController.this.isplaying.get()) {
|
||||||
|
MusicController.this.iv_play.setImage(pause_white);
|
||||||
|
}
|
||||||
|
if (!MusicController.this.isplaying.get()) {
|
||||||
|
MusicController.this.iv_play.setImage(play_white);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.iv_play.setOnMouseClicked(event -> {
|
||||||
|
if (event.getButton().equals(MouseButton.PRIMARY) && MusicController.this.mp != null) {
|
||||||
|
MusicController.this.isplaying.set(!MusicController.this.isplaying.get());
|
||||||
|
if (MusicController.this.isplaying.get()) {
|
||||||
|
MusicController.this.iv_play.setImage(pause_white);
|
||||||
|
} else {
|
||||||
|
MusicController.this.iv_play.setImage(play_white);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.isplaying.addListener((observable, oldValue, newValue) -> {
|
||||||
|
if (newValue) {
|
||||||
|
MusicController.this.iv_play.setImage(pause_white);
|
||||||
|
if (MusicController.this.mp.getStatus().equals(MediaPlayer.Status.PAUSED)) {
|
||||||
|
MusicController.this.mp.play();
|
||||||
|
} else {
|
||||||
|
MusicController.this.myPlay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!newValue) {
|
||||||
|
MusicController.this.iv_play.setImage(pause_black);
|
||||||
|
MusicController.this.mp.pause();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void myPlay() {
|
public void myPlay() {
|
||||||
this.mp.dispose();
|
this.mp.dispose();
|
||||||
this.mp = new MediaPlayer((Media) this.medias.get(this.playindex.get()));
|
this.mp = new MediaPlayer(this.medias.get(this.playindex.get()));
|
||||||
initProgressBar(mp);
|
initProgressBar(mp);
|
||||||
this.mp.setOnReady(new Runnable() {
|
this.mp.setOnReady(() -> {
|
||||||
public void run() {
|
MusicController.this.mp.play();
|
||||||
MusicController.this.mp.play();
|
MusicController.this.isplaying.set(true);
|
||||||
MusicController.this.isplaying.set(true);
|
load_lyric();
|
||||||
load_lyric();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
this.isplaying.set(true);
|
this.isplaying.set(true);
|
||||||
this.sb = new StringBuffer(((File) this.files.get(this.playindex.get())).getName());
|
this.sb = new StringBuffer(files.get(this.playindex.get()).getName());
|
||||||
this.label_name.setText(this.sb.substring(0, this.sb.length() - 4));
|
this.label_name.setText(this.sb.substring(0, this.sb.length() - 4));
|
||||||
this.mp.volumeProperty().bind(this.sl_vol.valueProperty());
|
|
||||||
this.mp.currentTimeProperty().addListener(new ChangeListener<Duration>() {
|
this.mp.setVolume(sl_vol_num);
|
||||||
public void changed(ObservableValue<? extends Duration> observable, Duration oldValue, Duration newValue) {
|
|
||||||
MusicController.this.playprogress.set(newValue.toSeconds() / MusicController.this.mp.getTotalDuration().toSeconds());
|
this.sl_vol.valueProperty().addListener((observableValue, number, t1) -> {
|
||||||
int m1 = (int) newValue.toMinutes();
|
log.info("音量调节:{}",t1.doubleValue());
|
||||||
int s1 = (int) (newValue.toSeconds() % 60.0D);
|
MusicController.this.mp.setVolume(t1.doubleValue() / 100);
|
||||||
int m2 = (int) MusicController.this.mp.getTotalDuration().toMinutes();
|
});
|
||||||
int s2 = (int) (MusicController.this.mp.getTotalDuration().toSeconds() % 60.0D);
|
|
||||||
MusicController.this.label_time.setText(m1 + ":" + s1 + " / " + m2 + ":" + s2);
|
this.mp.currentTimeProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
|
MusicController.this.playprogress.set(newValue.toSeconds() / MusicController.this.mp.getTotalDuration().toSeconds());
|
||||||
|
int m1 = (int) newValue.toMinutes();
|
||||||
|
int s1 = (int) (newValue.toSeconds() % 60.0D);
|
||||||
|
int m2 = (int) MusicController.this.mp.getTotalDuration().toMinutes();
|
||||||
|
int s2 = (int) (MusicController.this.mp.getTotalDuration().toSeconds() % 60.0D);
|
||||||
|
MusicController.this.label_time.setText(m1 + ":" + s1 + " / " + m2 + ":" + s2);
|
||||||
|
});
|
||||||
|
this.mp.setAudioSpectrumListener((timestamp, duration, magnitudes, phases) -> {
|
||||||
|
for (int i = 0; i < 100; ++i) {
|
||||||
|
MusicController.this.getHeight().get(i).set((magnitudes[i] + 60.0F) * 2.0F);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.mp.setAudioSpectrumListener(new AudioSpectrumListener() {
|
this.mp.setOnEndOfMedia(() -> {
|
||||||
public void spectrumDataUpdate(double timestamp, double duration, float[] magnitudes, float[] phases) {
|
if (MusicController.this.cycletype.get() == 0) {
|
||||||
for (int i = 0; i < 100; ++i) {
|
MusicController.this.playindex.set((MusicController.this.playindex.get() + 1) % medias.size());
|
||||||
((SimpleFloatProperty) MusicController.this.getHeight().get(i)).set((magnitudes[i] + 60.0F) * 2.0F);
|
} else if (MusicController.this.cycletype.get() == 1) {
|
||||||
}
|
MusicController.this.playindex.set(MusicController.this.playindex.get());
|
||||||
// Mp3Cover.getRx().set(150.0F + phases[0] * 5.0F);
|
MusicController.this.myPlay();
|
||||||
// Mp3Cover.getRy().set(150.0F + phases[0] * 5.0F);
|
} else {
|
||||||
}
|
MusicController.this.playindex.set(MusicController.this.playindex.get() + MusicController.this.ran.nextInt(medias.size()) % medias.size());
|
||||||
});
|
|
||||||
this.mp.setOnEndOfMedia(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
if (MusicController.this.cycletype.get() == 0) {
|
|
||||||
MusicController.this.playindex.set((MusicController.this.playindex.get() + 1) % medias.size());
|
|
||||||
} else if (MusicController.this.cycletype.get() == 1) {
|
|
||||||
MusicController.this.playindex.set(MusicController.this.playindex.get());
|
|
||||||
MusicController.this.myPlay();
|
|
||||||
} else {
|
|
||||||
MusicController.this.playindex.set(MusicController.this.playindex.get() + MusicController.this.ran.nextInt(medias.size()) % medias.size());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -553,15 +535,19 @@ public class MusicController {
|
||||||
placehold.setFont(Font.font(19.0D));
|
placehold.setFont(Font.font(19.0D));
|
||||||
listView.setPlaceholder(placehold);
|
listView.setPlaceholder(placehold);
|
||||||
|
|
||||||
listView.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, (CornerRadii)null, (Insets)null)));
|
listView.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, null, null)));
|
||||||
listView.setFixedCellSize(40.0D);
|
listView.setFixedCellSize(40.0D);
|
||||||
|
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>() {
|
||||||
protected void updateItem(File item, boolean empty) {
|
protected void updateItem(File item, boolean empty) {
|
||||||
super.updateItem(item, empty);
|
super.updateItem(item, empty);
|
||||||
if (!empty && item != null) {
|
if (!empty && item != null) {
|
||||||
StringBuffer sb = new StringBuffer(item.getName());
|
sb = new StringBuffer(item.getName());
|
||||||
Text text = new Text(sb.substring(0, sb.length() - 4));
|
Text text = new Text(sb.substring(0, sb.length() - 4));
|
||||||
text.setWrappingWidth(300.0D);
|
text.setWrappingWidth(300.0D);
|
||||||
text.setTextAlignment(TextAlignment.CENTER);
|
text.setTextAlignment(TextAlignment.CENTER);
|
||||||
|
|
@ -620,7 +606,6 @@ public class MusicController {
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initProgressBar(MediaPlayer player) {
|
private void initProgressBar(MediaPlayer player) {
|
||||||
|
|
@ -676,7 +661,7 @@ public class MusicController {
|
||||||
if (dirs.size() != 0) {
|
if (dirs.size() != 0) {
|
||||||
return dirs;
|
return dirs;
|
||||||
} else {
|
} else {
|
||||||
String dir = "D:\\KwDownload\\song";
|
String dir = config_path();
|
||||||
File file = new File(dir);
|
File file = new File(dir);
|
||||||
if (file.exists() && file.isDirectory()) {
|
if (file.exists() && file.isDirectory()) {
|
||||||
dirs.add(file);
|
dirs.add(file);
|
||||||
|
|
@ -685,6 +670,18 @@ public class MusicController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String config_path(){
|
||||||
|
Resource resource = new ClassPathResource("music.properties");
|
||||||
|
InputStream inputStream = resource.getStream();
|
||||||
|
Properties properties = new Properties();
|
||||||
|
try {
|
||||||
|
properties.load(inputStream);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return properties.getProperty("base.music.path");
|
||||||
|
}
|
||||||
|
|
||||||
public static ObservableList<Media> getMusicMedias() {
|
public static ObservableList<Media> getMusicMedias() {
|
||||||
if (medias.size() == 0) {
|
if (medias.size() == 0) {
|
||||||
getDirsList().forEach((dir) -> {
|
getDirsList().forEach((dir) -> {
|
||||||
|
|
@ -694,14 +691,12 @@ public class MusicController {
|
||||||
return name.endsWith("mp3");
|
return name.endsWith("mp3");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
String uri = file.toURI().toASCIIString();
|
String uri = file.toURI().toASCIIString();
|
||||||
Media media = new Media(uri);
|
Media media = new Media(uri);
|
||||||
medias.add(media);
|
medias.add(media);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
return medias;
|
return medias;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -720,7 +715,6 @@ public class MusicController {
|
||||||
});
|
});
|
||||||
files.addAll(mfiles);
|
files.addAll(mfiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
return files;
|
return files;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -795,6 +789,5 @@ public class MusicController {
|
||||||
} catch (IOException var2) {
|
} catch (IOException var2) {
|
||||||
var2.printStackTrace();
|
var2.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,109 @@
|
||||||
|
package com.zhangmeng.tools.controller;
|
||||||
|
|
||||||
|
import cn.hutool.core.io.resource.ClassPathResource;
|
||||||
|
import cn.hutool.core.io.resource.Resource;
|
||||||
|
import com.leewyatt.rxcontrols.pojo.PathInfo;
|
||||||
|
import com.leewyatt.rxcontrols.utils.SvgUtil;
|
||||||
|
import com.zhangmeng.tools.utils.AlertUtils;
|
||||||
|
import com.zhangmeng.tools.utils.ImagePath;
|
||||||
|
import com.zhangmeng.tools.utils.ResourcesUtils;
|
||||||
|
import com.zhangmeng.tools.utils.SvgUtils;
|
||||||
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.ListView;
|
||||||
|
import javafx.scene.control.TextField;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.layout.AnchorPane;
|
||||||
|
import javafx.scene.shape.SVGPath;
|
||||||
|
import javafx.stage.DirectoryChooser;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import javafx.stage.Window;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.xmlgraphics.util.ClasspathResource;
|
||||||
|
|
||||||
|
import java.awt.event.InputEvent;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : 芊芊墨客
|
||||||
|
* @version : 1.0
|
||||||
|
* @date : 2023-02-17 10:42
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class MusicSetController {
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Button file_choose_button;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private TextField text_file;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void initialize(){
|
||||||
|
log.info("music set ....");
|
||||||
|
file_choose_button.setText(null);
|
||||||
|
ImageView iv = new ImageView(new Image(ImagePath.path(ImagePath.ImagePathType.IMAGE_FILE)));
|
||||||
|
iv.setPreserveRatio(true);
|
||||||
|
iv.setFitWidth(18);
|
||||||
|
file_choose_button.setGraphic(iv);
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void choose_file(){
|
||||||
|
Stage stage = (Stage) file_choose_button.getScene().getWindow();
|
||||||
|
DirectoryChooser dc = new DirectoryChooser();
|
||||||
|
dc.setTitle("文件夹选择器");
|
||||||
|
File file = dc.showDialog(stage);
|
||||||
|
if (file != null){
|
||||||
|
String path = file.getAbsolutePath();
|
||||||
|
text_file.setText(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
public void commit() throws FileNotFoundException {
|
||||||
|
String path = text_file.getText();
|
||||||
|
if (path.length() == 0 ){
|
||||||
|
AlertUtils.alert_warning("请选择文件夹");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setPath(path);
|
||||||
|
//关闭
|
||||||
|
Stage stage = (Stage) text_file.getScene().getWindow();
|
||||||
|
Stage stageOwner = (Stage) stage.getOwner();
|
||||||
|
stage.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPath(String path){
|
||||||
|
Resource resource = new ClassPathResource("music.properties");
|
||||||
|
InputStream inputStream = resource.getStream();
|
||||||
|
FileOutputStream fileOutputStream = null;
|
||||||
|
Properties properties = new Properties();
|
||||||
|
try {
|
||||||
|
properties.load(inputStream);
|
||||||
|
String value = properties.getProperty("base.music.path");
|
||||||
|
log.info("path:{}",value);
|
||||||
|
properties.setProperty("base.music.path",path);
|
||||||
|
log.info("properties:{}",properties);
|
||||||
|
String out_path = Thread.currentThread().getContextClassLoader().getResource("").getPath() + "music.properties";
|
||||||
|
fileOutputStream = new FileOutputStream(out_path);
|
||||||
|
properties.store(fileOutputStream,"保存");
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.info("选择路径出错!");
|
||||||
|
}finally {
|
||||||
|
try {
|
||||||
|
inputStream.close();
|
||||||
|
if (fileOutputStream != null){
|
||||||
|
fileOutputStream.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.zhangmeng.tools.utils;
|
||||||
|
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Alert;
|
||||||
|
import javafx.stage.Modality;
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import javafx.stage.StageStyle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : 芊芊墨客
|
||||||
|
* @version : 1.0
|
||||||
|
* @date : 2023-02-17 09:59
|
||||||
|
*/
|
||||||
|
public class AlertUtils {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 警告弹窗
|
||||||
|
*/
|
||||||
|
public static void alert_warning(String msg) {
|
||||||
|
Alert alert = new Alert(Alert.AlertType.WARNING);
|
||||||
|
alert.initModality(Modality.APPLICATION_MODAL);
|
||||||
|
alert.setContentText(msg);
|
||||||
|
alert.setHeaderText(null);
|
||||||
|
alert.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void alert(String title, Parent node, Stage primaryStage){
|
||||||
|
alert(title,node,600,400,primaryStage);
|
||||||
|
}
|
||||||
|
public static void alert(String title, Parent node, int width, int height, Stage primaryStage) {
|
||||||
|
Scene scene = new Scene(node);
|
||||||
|
Stage stage = new Stage();
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.setTitle(title);
|
||||||
|
stage.setWidth(width);
|
||||||
|
stage.setHeight(height);
|
||||||
|
stage.initStyle(StageStyle.UTILITY);
|
||||||
|
stage.initOwner(primaryStage);
|
||||||
|
stage.initModality(Modality.APPLICATION_MODAL);
|
||||||
|
stage.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -47,6 +47,8 @@ public class ImagePath {
|
||||||
ICON_WHITE_RANDOM("随机白色图标"),
|
ICON_WHITE_RANDOM("随机白色图标"),
|
||||||
ICON_BLACK_RANDOM("随机黑色图标"),
|
ICON_BLACK_RANDOM("随机黑色图标"),
|
||||||
|
|
||||||
|
IMAGE_FILE("文件图标"),
|
||||||
|
|
||||||
ICON_NULL_COVER("");
|
ICON_NULL_COVER("");
|
||||||
|
|
||||||
private String desc;
|
private String desc;
|
||||||
|
|
@ -218,6 +220,8 @@ public class ImagePath {
|
||||||
|
|
||||||
public static String ICON_NULL_COVER = "bgimg/2041075.jpg";
|
public static String ICON_NULL_COVER = "bgimg/2041075.jpg";
|
||||||
|
|
||||||
|
public static String SVG_FILE = "svg/file.png";
|
||||||
|
|
||||||
public static String path(ImagePathType type) {
|
public static String path(ImagePathType type) {
|
||||||
|
|
||||||
String path = null;
|
String path = null;
|
||||||
|
|
@ -341,6 +345,9 @@ public class ImagePath {
|
||||||
case TOP_VIEW_Full_BLACK:
|
case TOP_VIEW_Full_BLACK:
|
||||||
path = ImagePath.TOP_VIEW_Full_BLACK;
|
path = ImagePath.TOP_VIEW_Full_BLACK;
|
||||||
break;
|
break;
|
||||||
|
case IMAGE_FILE:
|
||||||
|
path = ImagePath.SVG_FILE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return "static/" + path;
|
return "static/" + path;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ public class MusicConstant {
|
||||||
|
|
||||||
public static OS getOS(){
|
public static OS getOS(){
|
||||||
String property = System.getProperty("os.name");
|
String property = System.getProperty("os.name");
|
||||||
System.out.println(property);
|
|
||||||
if (property.contains("Windows")){
|
if (property.contains("Windows")){
|
||||||
return OS.windows;
|
return OS.windows;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.zhangmeng.tools.utils;
|
||||||
|
|
||||||
|
import javafx.scene.Group;
|
||||||
|
import javafx.scene.Parent;
|
||||||
|
import javafx.scene.shape.SVGPath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author : 芊芊墨客
|
||||||
|
* @version : 1.0
|
||||||
|
* @date : 2023-02-17 10:58
|
||||||
|
*/
|
||||||
|
public class SvgUtils {
|
||||||
|
|
||||||
|
public static Parent svg(String content) {
|
||||||
|
SVGPath svgPath = new SVGPath();
|
||||||
|
svgPath.setContent(content);
|
||||||
|
return new Group(svgPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.Label?>
|
||||||
|
<?import javafx.scene.control.TextField?>
|
||||||
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
|
|
||||||
|
<AnchorPane prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/19" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.zhangmeng.tools.controller.MusicSetController">
|
||||||
|
<children>
|
||||||
|
<Label layoutX="84.0" layoutY="131.0" text="歌曲目录" AnchorPane.topAnchor="131.0" />
|
||||||
|
<TextField fx:id="text_file" layoutX="148.0" layoutY="127.0" prefHeight="25.0" prefWidth="305.0" />
|
||||||
|
<Button fx:id="file_choose_button" layoutX="472.0" layoutY="127.0" mnemonicParsing="false" onAction="#choose_file" text="Button" />
|
||||||
|
<Button layoutX="256.0" layoutY="250.0" mnemonicParsing="false" onAction="#commit" prefHeight="31.0" prefWidth="105.0" text="应用" />
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
base.music.path = D:\\KwDownload\\song
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 8.5 KiB |
|
|
@ -1,12 +1,18 @@
|
||||||
package com.zhangmeng.tools;
|
package com.zhangmeng.tools;
|
||||||
|
|
||||||
|
import com.zhangmeng.tools.utils.AlertUtils;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.Parent;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.media.Media;
|
import javafx.scene.media.Media;
|
||||||
import javafx.scene.media.MediaPlayer;
|
import javafx.scene.media.MediaPlayer;
|
||||||
|
import javafx.stage.Modality;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import javafx.stage.StageStyle;
|
||||||
|
import javafx.stage.Window;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
|
|
@ -21,16 +27,35 @@ public class Main extends Application {
|
||||||
public void start(Stage primaryStage) throws Exception {
|
public void start(Stage primaryStage) throws Exception {
|
||||||
Button button = new Button("1111");
|
Button button = new Button("1111");
|
||||||
AnchorPane anchorPane = new AnchorPane();
|
AnchorPane anchorPane = new AnchorPane();
|
||||||
|
|
||||||
URL url = this.getClass().getClassLoader().getResource("mp3/薛晓枫-最后一次.mp3");
|
|
||||||
|
|
||||||
Media media = new Media(url.toExternalForm());
|
|
||||||
MediaPlayer mediaPlayer = new MediaPlayer(media);
|
|
||||||
|
|
||||||
anchorPane.getChildren().add(button);
|
anchorPane.getChildren().add(button);
|
||||||
|
|
||||||
|
button.setOnAction(event -> {
|
||||||
|
|
||||||
|
AnchorPane pane = new AnchorPane();
|
||||||
|
pane.getChildren().add(new Button("66666"));
|
||||||
|
|
||||||
|
alert("弹窗",pane,primaryStage);
|
||||||
|
});
|
||||||
primaryStage.setScene(new Scene(anchorPane));
|
primaryStage.setScene(new Scene(anchorPane));
|
||||||
|
primaryStage.setTitle("test");
|
||||||
|
primaryStage.setWidth(800);
|
||||||
|
primaryStage.setHeight(600);
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public static void alert(String title, Parent node,Stage primaryStage){
|
||||||
|
alert(title,node,600,400,primaryStage);
|
||||||
|
}
|
||||||
|
public static void alert(String title, Parent node, int width, int height, Stage primaryStage) {
|
||||||
|
Scene scene = new Scene(node);
|
||||||
|
Stage stage = new Stage();
|
||||||
|
stage.setScene(scene);
|
||||||
|
stage.setTitle(title);
|
||||||
|
stage.setWidth(width);
|
||||||
|
stage.setHeight(height);
|
||||||
|
stage.initStyle(StageStyle.UTILITY);
|
||||||
|
stage.initOwner(primaryStage);
|
||||||
|
stage.initModality(Modality.APPLICATION_MODAL);
|
||||||
|
stage.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue