⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 songinfodialog.java

📁 YOYOPlayer MP3播放器 java+JMF实现
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * SongInfoDialog.java * * Created on 2007年11月26日, 下午4:12 */package com.hadeslee.yoyoplayer.tag;import com.hadeslee.audiotag.audio.flac.FlacTagWriter;import com.hadeslee.audiotag.audio.flac.metadatablock.MetadataBlockDataPicture;import com.hadeslee.audiotag.audio.mp3.MP3File;import com.hadeslee.audiotag.audio.ogg.OggVorbisTagWriter;import com.hadeslee.audiotag.tag.ape.APEv2Tag;import com.hadeslee.audiotag.tag.flac.FlacTag;import com.hadeslee.audiotag.tag.id3.ID3v1Tag;import com.hadeslee.audiotag.tag.id3.ID3v24Tag;import com.hadeslee.audiotag.tag.vorbiscomment.VorbisCommentTag;import com.hadeslee.yoyoplayer.playlist.PlayListItem;import com.hadeslee.yoyoplayer.util.Config;import com.hadeslee.yoyoplayer.util.Util;import java.awt.Dialog;import java.awt.Frame;import java.io.File;import java.io.RandomAccessFile;import java.util.ArrayList;import java.util.logging.Level;import java.util.logging.Logger;import javax.swing.JOptionPane;/** * * @author  hadeslee */public class SongInfoDialog extends javax.swing.JDialog {    private static final long serialVersionUID = 20071214L;    private static Logger log = Logger.getLogger(SongInfoDialog.class.getName());    private PlayListItem item;//播放列表的项    private boolean valid;//表示原来这个文件是不是合法的,如果不是,就要重新写入128个字节    private static final int[] writeMode = {Config.WRITEMODE_ID3v1,     Config.WRITEMODE_ID3v2, Config.WRITEMODE_APEv2,        Config.WRITEMODE_APEv2 | Config.WRITEMODE_ID3v1,        Config.WRITEMODE_ID3v1 | Config.WRITEMODE_ID3v2,        Config.WRITEMODE_APEv2| Config.WRITEMODE_ID3v2    };    private static final int[] readOrder = {Config.APEv2_ID3v2_ID3v1, Config.ID3v2_APEv2_ID3v1,        Config.ID3v1_APEv2_ID3v2, Config.ID3v1_ID3v2_APEv2    };    /** Creates new form SongInfoDialog */    public SongInfoDialog(java.awt.Frame parent, boolean modal) {        super(parent, modal);        initComponents();        initOther();    }    public SongInfoDialog(Dialog parent, boolean modal) {        super(parent, modal);        initComponents();        initOther();    }    public SongInfoDialog(Frame parent, boolean modal, PlayListItem item) {        this(parent, modal);        this.item = item;        init();    }    public SongInfoDialog(Dialog parent, boolean modal, PlayListItem item) {        this(parent, modal);        this.item = item;        init();    }    private void initOther() {        int index = 0;        for (int i = 0; i < readOrder.length; i++) {            int order = Config.getConfig().getReadTagOrder();            if (order == readOrder[i]) {                index = i;                break;            }        }        jComboBox1.setSelectedIndex(index);        index = 0;        for (int i = 0; i < writeMode.length; i++) {            int mode = Config.getConfig().getWriteTagMode();            if (mode == writeMode[i]) {                index = i;                break;            }        }        jComboBox2.setSelectedIndex(index);        this.setLocationRelativeTo(null);    }    /**     * 初始化     */    private void init() {        try {            fileName.setText(item.getLocation());            title.setText(item.getTitle());            artist.setText(item.getArtist());            album.setText(item.getAlbum());            genre.setText(item.getGenre());            track.setText(item.getTrack());            comment.setText(item.getComment());            year.setText(item.getYear());        } catch (Exception ex) {            Logger.getLogger(SongInfoDialog.class.getName()).log(Level.SEVERE, null, ex);        }    }    /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents    private void initComponents() {        jLabel5 = new javax.swing.JLabel();        fileName = new javax.swing.JTextField();        jPanel1 = new javax.swing.JPanel();        jLabel1 = new javax.swing.JLabel();        title = new javax.swing.JTextField();        jLabel2 = new javax.swing.JLabel();        artist = new javax.swing.JTextField();        jLabel3 = new javax.swing.JLabel();        jLabel4 = new javax.swing.JLabel();        album = new javax.swing.JTextField();        jLabel6 = new javax.swing.JLabel();        track = new javax.swing.JTextField();        year = new javax.swing.JTextField();        jLabel7 = new javax.swing.JLabel();        genre = new javax.swing.JTextField();        jLabel8 = new javax.swing.JLabel();        jScrollPane1 = new javax.swing.JScrollPane();        comment = new javax.swing.JTextArea();        jButton1 = new javax.swing.JButton();        jButton2 = new javax.swing.JButton();        jButton3 = new javax.swing.JButton();        jPanel2 = new javax.swing.JPanel();        jLabel9 = new javax.swing.JLabel();        jComboBox1 = new javax.swing.JComboBox();        jLabel10 = new javax.swing.JLabel();        jComboBox2 = new javax.swing.JComboBox();        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);        setTitle("歌曲信息");        jLabel5.setText(Config.getResource("SongInfoDialog.fileName")); // NOI18N        fileName.setEditable(false);        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(Config.getResource("SongInfoDialog.tag"))); // NOI18N        jLabel1.setText(Config.getResource("SongInfoDialog.title")); // NOI18N        jLabel2.setText(Config.getResource("SongInfoDialog.artist")); // NOI18N        jLabel3.setText(Config.getResource("SongInfoDialog.album")); // NOI18N        jLabel4.setText(Config.getResource("SongInfoDialog.year")); // NOI18N        jLabel6.setText(Config.getResource("SongInfoDialog.track")); // NOI18N        jLabel7.setText(Config.getResource("SongInfoDialog.genre")); // NOI18N        jLabel8.setText(Config.getResource("SongInfoDialog.comment")); // NOI18N        comment.setColumns(20);        comment.setFont(new java.awt.Font("Dialog", 0, 12));        comment.setLineWrap(true);        comment.setRows(5);        jScrollPane1.setViewportView(comment);        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);        jPanel1.setLayout(jPanel1Layout);        jPanel1Layout.setHorizontalGroup(            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel1Layout.createSequentialGroup()                .addContainerGap()                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addGroup(jPanel1Layout.createSequentialGroup()                        .addComponent(jLabel1)                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                        .addComponent(title, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE))                    .addGroup(jPanel1Layout.createSequentialGroup()                        .addComponent(jLabel2)                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                        .addComponent(artist, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)                        .addContainerGap())                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                            .addGroup(jPanel1Layout.createSequentialGroup()                                .addComponent(jLabel3)                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                                .addComponent(album, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE))                            .addGroup(jPanel1Layout.createSequentialGroup()                                .addComponent(jLabel7)                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                                .addComponent(genre, javax.swing.GroupLayout.DEFAULT_SIZE, 110, Short.MAX_VALUE)))                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                            .addGroup(jPanel1Layout.createSequentialGroup()                                .addComponent(jLabel4)                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                                .addComponent(year, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))                            .addGroup(jPanel1Layout.createSequentialGroup()                                .addComponent(jLabel6)                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                                .addComponent(track, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))                        .addContainerGap())                    .addGroup(jPanel1Layout.createSequentialGroup()                        .addComponent(jLabel8)                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)                        .addContainerGap())))        );        jPanel1Layout.setVerticalGroup(            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel1Layout.createSequentialGroup()                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel1)                    .addComponent(title, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel2)                    .addComponent(artist, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel3)                    .addComponent(track, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(jLabel6)                    .addComponent(album, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)                    .addComponent(jLabel4)                    .addComponent(year, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)                    .addComponent(jLabel7)                    .addComponent(genre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)                    .addComponent(jLabel8)                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)))        );        jButton1.setText(Config.getResource("SongInfoDialog.reReadFile")); // NOI18N        jButton1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton1ActionPerformed(evt);            }        });        jButton2.setText(Config.getResource("SongInfoDialog.saveToFile")); // NOI18N        jButton2.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton2ActionPerformed(evt);            }        });        jButton3.setText(Config.getResource("SongInfoDialog.cancel")); // NOI18N        jButton3.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jButton3ActionPerformed(evt);            }        });        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(Config.getResource("SongInfoDialog.mp3tag"))); // NOI18N        jLabel9.setText(Config.getResource("SongInfoDialog.readOrder")); // NOI18N        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "APEv2 > ID3v2 > ID3v1", "ID3v2 > APEv2 > ID3v1", "ID3v1 > APEv2 > ID3v2", "ID3v1 > ID3v2 > APEv2" }));        jComboBox1.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jComboBox1ActionPerformed(evt);            }        });        jLabel10.setText(Config.getResource("SongInfoDialog.writeMode")); // NOI18N        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ID3v1", "ID3v2", "APEv2", "ID3v1&APEv2", "ID3v1&ID3v2", "ID3v2&APEv2" }));        jComboBox2.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                jComboBox2ActionPerformed(evt);            }        });        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);        jPanel2.setLayout(jPanel2Layout);        jPanel2Layout.setHorizontalGroup(            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)            .addGroup(jPanel2Layout.createSequentialGroup()                .addComponent(jLabel9)                .addContainerGap(203, Short.MAX_VALUE))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -