完善影音工具单例化 2023年2月18日09:23:12
parent
ce74eed863
commit
31905312fc
|
|
@ -29,6 +29,7 @@ import javafx.stage.Stage;
|
|||
import javafx.util.Callback;
|
||||
import javafx.util.StringConverter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.actuate.trace.http.TraceableRequest;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -45,14 +46,16 @@ public class PlayerController {
|
|||
private SimpleDoubleProperty height = new SimpleDoubleProperty(0.0);
|
||||
private AnchorPane root;
|
||||
|
||||
private AnchorPane video;
|
||||
private AnchorPane music;
|
||||
private AnchorPane vip_parser;
|
||||
|
||||
@FXML
|
||||
private ListView<ResourcesUtils.Player> listView;
|
||||
|
||||
@FXML
|
||||
private SplitPane splitPane;
|
||||
|
||||
private MediaView view;
|
||||
|
||||
public static final String color_cell = "#f4f4f4";
|
||||
|
||||
@FXML
|
||||
|
|
@ -67,17 +70,29 @@ public class PlayerController {
|
|||
|
||||
@FXML
|
||||
public void video_menu_item() {
|
||||
video();
|
||||
boolean flag = false;
|
||||
if (video != null) {
|
||||
flag = true;
|
||||
}
|
||||
video(flag);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void music_menu_item() {
|
||||
music();
|
||||
boolean flag = false;
|
||||
if (music != null) {
|
||||
flag = true;
|
||||
}
|
||||
music(flag);
|
||||
}
|
||||
|
||||
@FXML
|
||||
public void vip_parser_menu_item() {
|
||||
vip_parser();
|
||||
boolean flag = false;
|
||||
if (vip_parser != null) {
|
||||
flag = true;
|
||||
}
|
||||
vip_parser(flag);
|
||||
}
|
||||
|
||||
public void load_encrypt() {
|
||||
|
|
@ -99,25 +114,36 @@ public class PlayerController {
|
|||
init();
|
||||
listView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (newValue != null) {
|
||||
boolean flag = false;
|
||||
|
||||
if (newValue.getIndex() == 0) {
|
||||
video();
|
||||
if (video != null) {
|
||||
flag = true;
|
||||
}
|
||||
video(flag);
|
||||
}
|
||||
if (newValue.getIndex() == 1) {
|
||||
music();
|
||||
if (music != null) {
|
||||
flag = true;
|
||||
}
|
||||
music(flag);
|
||||
}
|
||||
if (newValue.getIndex() == 2) {
|
||||
vip_parser();
|
||||
if (vip_parser != null) {
|
||||
flag = true;
|
||||
}
|
||||
vip_parser(flag);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Image getImage(ResourcesUtils.Player player){
|
||||
return switch (player){
|
||||
case Video -> new Image(ImagePath.path(ImagePath.ImagePathType.VIDEO_PLAYER));
|
||||
case Music -> new Image(ImagePath.path(ImagePath.ImagePathType.MUSIC_PLAYER));
|
||||
case VipParser -> new Image(ImagePath.path(ImagePath.ImagePathType.VIP_PLAYER));
|
||||
};
|
||||
public static Image getImage(ResourcesUtils.Player player) {
|
||||
return switch (player) {
|
||||
case Video -> new Image(ImagePath.path(ImagePath.ImagePathType.VIDEO_PLAYER));
|
||||
case Music -> new Image(ImagePath.path(ImagePath.ImagePathType.MUSIC_PLAYER));
|
||||
case VipParser -> new Image(ImagePath.path(ImagePath.ImagePathType.VIP_PLAYER));
|
||||
};
|
||||
}
|
||||
|
||||
public void init() {
|
||||
|
|
@ -164,7 +190,7 @@ public class PlayerController {
|
|||
label.setFont(new Font(16));
|
||||
playerListView.getFocusModel().focus(position);
|
||||
listCell.setStyle("-fx-background-color: #f6edc3");
|
||||
}else {
|
||||
} else {
|
||||
label.setPrefHeight(20);
|
||||
label.setFont(new Font(13));
|
||||
listCell.setStyle("-fx-background-color: " + color_cell);
|
||||
|
|
@ -175,25 +201,53 @@ public class PlayerController {
|
|||
return listCell;
|
||||
}
|
||||
});
|
||||
video();
|
||||
video(false);
|
||||
}
|
||||
|
||||
private void music() {
|
||||
private void music(boolean flag) {
|
||||
listView.getSelectionModel().select(1);
|
||||
try {
|
||||
root = FXMLLoader.load(ResourcesUtils.getResource("music"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
if (!flag) {
|
||||
try {
|
||||
root = FXMLLoader.load(ResourcesUtils.getResource("music"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
music = root;
|
||||
} else {
|
||||
root = music;
|
||||
}
|
||||
common_method();
|
||||
}
|
||||
|
||||
private void vip_parser() {
|
||||
private void vip_parser(boolean flag) {
|
||||
listView.getSelectionModel().select(2);
|
||||
try {
|
||||
root = FXMLLoader.load(ResourcesUtils.getResource("vip-parser"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
if (!flag) {
|
||||
try {
|
||||
root = FXMLLoader.load(ResourcesUtils.getResource("vip-parser"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
vip_parser = root;
|
||||
} else {
|
||||
root = vip_parser;
|
||||
}
|
||||
common_method();
|
||||
}
|
||||
|
||||
private void video(boolean flag) {
|
||||
//默认选择第一个
|
||||
listView.getSelectionModel().select(0);
|
||||
|
||||
if (!flag) {
|
||||
try {
|
||||
root = FXMLLoader.load(ResourcesUtils.getResource("video"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
video = root;
|
||||
} else {
|
||||
root = video;
|
||||
}
|
||||
common_method();
|
||||
}
|
||||
|
|
@ -215,29 +269,15 @@ public class PlayerController {
|
|||
log.info("player:--->height:{}", height);
|
||||
}
|
||||
});
|
||||
view = (MediaView)root.lookup("#mv");
|
||||
view.fitHeightProperty().bind(root.heightProperty());
|
||||
view.fitWidthProperty().bind(root.widthProperty());
|
||||
|
||||
this.width.addListener((observable, oldValue, newValue) -> {
|
||||
PlayerController.this.root.setPrefWidth(newValue.doubleValue() - listView.getWidth());
|
||||
log.info("newValue.doubleValue():{}",newValue.doubleValue());
|
||||
log.info("newValue.doubleValue():{}", newValue.doubleValue());
|
||||
});
|
||||
|
||||
this.height.addListener((observable, oldValue, newValue) -> {
|
||||
PlayerController.this.root.setPrefHeight(newValue.doubleValue() - listView.getHeight());
|
||||
log.info("newValue.doubleValue():{}" ,newValue.doubleValue());
|
||||
log.info("newValue.doubleValue():{}", newValue.doubleValue());
|
||||
});
|
||||
}
|
||||
|
||||
private void video() {
|
||||
//默认选择第一个
|
||||
listView.getSelectionModel().select(0);
|
||||
try {
|
||||
root = FXMLLoader.load(ResourcesUtils.getResource("video"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
common_method();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue