Skip to content

Commit

Permalink
Open txt file passed in run args (#37)
Browse files Browse the repository at this point in the history
Support opening TXT files with Karedi from txt file context menu on Windows.
  • Loading branch information
Nianna committed Sep 20, 2023
1 parent 088afa3 commit 973d378
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 189 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/github/nianna/karedi/KarediApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ public void initRootLayout() {
mp3Filter = new FileChooser.ExtensionFilter(I18N.get("filechooser.mp3_files"), "*.mp3");

primaryStage.show();

controller.onStageShown();
} catch (IOException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,20 @@ public void loadSongFile(File file) {
}

public void loadSongFile(File file, boolean resetPlayer) {
if (file != null) {
if (file == null) {
return;
}

if (file.exists()) {
reset(resetPlayer);
setActiveFile(file);
Song song = txtFacade.loadFromTxtFile(file);
song.getTagValue(TagKey.MP3)
.ifPresent(audioFileName -> audioContext.loadAudioFile(new File(file.getParent(), audioFileName)));
activeSongContext.setSong(song);
LOGGER.info(I18N.get("load.success"));
} else {
LOGGER.severe(I18N.get("load.fail"));
}
}

Expand Down
Loading

0 comments on commit 973d378

Please sign in to comment.