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);
|
||||||
|
|
@ -312,7 +311,7 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
@ -670,19 +669,13 @@ public class VideoController {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ObservableList<File> getDirsList() {
|
public static ObservableList<File> getDirsList() {
|
||||||
if (dirs.size() != 0) {
|
|
||||||
return dirs;
|
|
||||||
} else {
|
|
||||||
String dir = config_path();
|
String dir = config_path();
|
||||||
// dir = new String(dir.getBytes(), Charset.forName(LRC_CODE));
|
|
||||||
dir = "F:\\B站\\JavaFX视频教程\\1到30课";
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
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");
|
||||||
|
|
@ -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