完善影音工具单例化 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,14 +114,25 @@ 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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -175,26 +201,54 @@ public class PlayerController {
|
|||
return listCell;
|
||||
}
|
||||
});
|
||||
video();
|
||||
video(false);
|
||||
}
|
||||
|
||||
private void music() {
|
||||
private void music(boolean flag) {
|
||||
listView.getSelectionModel().select(1);
|
||||
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);
|
||||
|
||||
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,9 +269,6 @@ 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());
|
||||
|
|
@ -229,15 +280,4 @@ public class PlayerController {
|
|||
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