2023年2月18日12:13:24 完善视频路径设置
parent
f521588043
commit
d798ac1665
|
|
@ -163,9 +163,6 @@ public class VideoController {
|
|||
@FXML
|
||||
private AnchorPane video_root;
|
||||
|
||||
@FXML
|
||||
private AnchorPane mv_an;
|
||||
|
||||
public void full_screen() {
|
||||
|
||||
AnchorPane root = null;
|
||||
|
|
@ -206,7 +203,9 @@ public class VideoController {
|
|||
public void onChanged(Change<? extends Media> c) {
|
||||
while (c.next()) {
|
||||
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) {
|
||||
VideoController.this.isplaying.set(false);
|
||||
|
|
@ -312,7 +311,7 @@ public class VideoController {
|
|||
if (event.getClickCount() == 1 && event.getButton() == MouseButton.PRIMARY) {
|
||||
AnchorPane root = null;
|
||||
try {
|
||||
root = FXMLLoader.load(ResourcesUtils.getResource("music-set"));
|
||||
root = FXMLLoader.load(ResourcesUtils.getResource("video-set"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
@ -670,19 +669,13 @@ public class VideoController {
|
|||
}
|
||||
|
||||
public static ObservableList<File> getDirsList() {
|
||||
if (dirs.size() != 0) {
|
||||
return dirs;
|
||||
} else {
|
||||
String dir = config_path();
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
public static String config_path() {
|
||||
Resource resource = new ClassPathResource("video.properties");
|
||||
|
|
@ -733,13 +726,12 @@ public class VideoController {
|
|||
}
|
||||
|
||||
public static void addDir(File file) {
|
||||
dirs.add(file);
|
||||
File[] addfiles = file.listFiles(new FilenameFilter() {
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith("mp4");
|
||||
}
|
||||
});
|
||||
|
||||
files.clear();
|
||||
for (int i = 0; i < addfiles.length; ++i) {
|
||||
Media media = new Media(addfiles[i].toURI().toASCIIString());
|
||||
medias.add(media);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ public class VideoSetController {
|
|||
@FXML
|
||||
private TextField text_file;
|
||||
|
||||
private File file;
|
||||
|
||||
@FXML
|
||||
public void initialize(){
|
||||
log.info("music set ....");
|
||||
|
|
@ -45,12 +47,13 @@ public class VideoSetController {
|
|||
Stage stage = (Stage) file_choose_button.getScene().getWindow();
|
||||
DirectoryChooser dc = new DirectoryChooser();
|
||||
dc.setTitle("文件夹选择器");
|
||||
File file = dc.showDialog(stage);
|
||||
file = dc.showDialog(stage);
|
||||
if (file != null){
|
||||
String path = file.getAbsolutePath();
|
||||
text_file.setText(path);
|
||||
}else {
|
||||
AlertUtils.alert_warning("请选择文件夹!");
|
||||
}
|
||||
VideoController.addDir(file);
|
||||
}
|
||||
|
||||
@FXML
|
||||
|
|
@ -64,6 +67,11 @@ public class VideoSetController {
|
|||
//关闭
|
||||
Stage stage = (Stage) text_file.getScene().getWindow();
|
||||
stage.close();
|
||||
|
||||
if (file != null){
|
||||
VideoController.addDir(file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue