From 3bb875f60ce8912ae3a303ff7c712a79fb143633 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Sun, 5 Mar 2023 18:58:09 -0800 Subject: Added listen button to open file using default app when editing tags --- src/main/java/FileUtility.java | 2 +- src/main/java/TagEditorScreen.form | 13 ++++++++++++- src/main/java/TagEditorScreen.java | 25 +++++++++++++++++++++++-- 3 files changed, 36 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/main/java/FileUtility.java b/src/main/java/FileUtility.java index fbe7f80..067e9ea 100644 --- a/src/main/java/FileUtility.java +++ b/src/main/java/FileUtility.java @@ -84,7 +84,7 @@ public class FileUtility { } return map; } - + public void moveFile(String source, String destination) { File sourceFile = new File(source); File destinationFile = new File(destination); diff --git a/src/main/java/TagEditorScreen.form b/src/main/java/TagEditorScreen.form index 828484c..48133ed 100644 --- a/src/main/java/TagEditorScreen.form +++ b/src/main/java/TagEditorScreen.form @@ -14,6 +14,8 @@ + + @@ -93,7 +95,7 @@ - + @@ -152,6 +154,15 @@ + + + + + + + + + diff --git a/src/main/java/TagEditorScreen.java b/src/main/java/TagEditorScreen.java index 764404c..ee6d911 100644 --- a/src/main/java/TagEditorScreen.java +++ b/src/main/java/TagEditorScreen.java @@ -2,6 +2,7 @@ import org.jaudiotagger.audio.*; import org.jaudiotagger.tag.FieldKey; import org.jaudiotagger.tag.Tag; import org.jaudiotagger.tag.datatype.Artwork; +import java.io.File; import javax.imageio.ImageIO; import javax.swing.*; @@ -26,6 +27,7 @@ public class TagEditorScreen extends JFrame{ private JButton applyChangesButton; private JLabel artIconLabel; private JTextField textField2; + private JButton listenButton; private FileUtility fileUtil = new FileUtility(); private String setDirPath = ""; private String selectedAlbumArt = ""; @@ -37,8 +39,9 @@ public class TagEditorScreen extends JFrame{ this.setContentPane(mainPanel); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.setLocationRelativeTo(null); - this.setSize(600, 450); + this.setSize(700, 550); initializeTable(); + listenButton.setEnabled(false); this.setVisible(true); chooseAudioDirectoryButton.addActionListener(new ActionListener() { @Override @@ -133,6 +136,15 @@ public class TagEditorScreen extends JFrame{ } + } + }); + listenButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + System.out.println("CURRENT PATH " + currPath); + playMP3(currPath); + + } }); } @@ -167,7 +179,7 @@ public class TagEditorScreen extends JFrame{ ImageIcon albumArtIcon = new ImageIcon(resizeImage(albumArt.getImage(),320,180)); artIconLabel.setIcon(albumArtIcon); artIconLabel.setText(""); - + listenButton.setEnabled(true); } catch (Exception e){ @@ -182,5 +194,14 @@ public class TagEditorScreen extends JFrame{ return outputImage; } + public void playMP3(String filepath){ + try { + File file = new File(filepath); + Desktop.getDesktop().open(file); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } -- cgit v1.2.3