當前位置: 首頁>>代碼示例>>Java>>正文


Java AudioFileFormat.properties方法代碼示例

本文整理匯總了Java中javax.sound.sampled.AudioFileFormat.properties方法的典型用法代碼示例。如果您正苦於以下問題:Java AudioFileFormat.properties方法的具體用法?Java AudioFileFormat.properties怎麽用?Java AudioFileFormat.properties使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.sound.sampled.AudioFileFormat的用法示例。


在下文中一共展示了AudioFileFormat.properties方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateLength

import javax.sound.sampled.AudioFileFormat; //導入方法依賴的package包/類
/**
 * Description of the Method
 */
public void updateLength() {
    int i = getSelectedRow();
    if (i < 0) {
        return;
    }

    boolean changed = false;
    Vector<YassSong> sel = getSelectedSongs();
    for (Enumeration<YassSong> en = sel.elements(); en.hasMoreElements(); ) {
        YassSong s = en.nextElement();

        String dir = s.getDirectory();
        String mp3 = s.getMP3();

        File file = new File(dir + File.separator + mp3);
        if (file.exists()) {
            try {
                AudioFileFormat baseFileFormat = AudioSystem.getAudioFileFormat(file);
                if (baseFileFormat instanceof TAudioFileFormat) {
                    Map<?, ?> properties = baseFileFormat.properties();
                    Long dur = (Long) properties.get("duration");
                    long sec = Math.round(dur.longValue() / 1000000.0);
                    s.setLength(sec + "");
                    s.setSaved(false);
                    changed = true;
                }
            } catch (Exception e) {
            }
        }
    }
    if (changed) {
        setSaved(false);
    }
    repaint();
}
 
開發者ID:SarutaSan72,項目名稱:Yass,代碼行數:39,代碼來源:YassSongList.java

示例2: updateAlbum

import javax.sound.sampled.AudioFileFormat; //導入方法依賴的package包/類
/**
 * Description of the Method
 */
public void updateAlbum() {
    int i = getSelectedRow();
    if (i < 0) {
        return;
    }

    boolean changed = false;
    Vector<YassSong> sel = getSelectedSongs();
    for (Enumeration<YassSong> en = sel.elements(); en.hasMoreElements(); ) {
        YassSong s = en.nextElement();

        String dir = s.getDirectory();
        String mp3 = s.getMP3();

        File file = new File(dir + File.separator + mp3);
        if (file.exists()) {
            try {
                AudioFileFormat baseFileFormat = AudioSystem.getAudioFileFormat(file);
                if (baseFileFormat instanceof TAudioFileFormat) {
                    Map<?, ?> properties = baseFileFormat.properties();
                    String a = (String) properties.get("album");
                    if (a != null && a.trim().length() > 0) {
                        s.setAlbum(a);
                        s.setSaved(false);
                        changed = true;
                    }
                }
            } catch (Exception e) {
            }
        }
    }
    if (changed) {
        setSaved(false);
    }
    repaint();
}
 
開發者ID:SarutaSan72,項目名稱:Yass,代碼行數:40,代碼來源:YassSongList.java

示例3: updateYear

import javax.sound.sampled.AudioFileFormat; //導入方法依賴的package包/類
/**
 * Description of the Method
 */
public void updateYear() {
    int i = getSelectedRow();
    if (i < 0) {
        return;
    }

    boolean changed = false;
    Vector<YassSong> sel = getSelectedSongs();
    for (Enumeration<YassSong> en = sel.elements(); en.hasMoreElements(); ) {
        YassSong s = en.nextElement();

        String dir = s.getDirectory();
        String mp3 = s.getMP3();

        File file = new File(dir + File.separator + mp3);
        if (file.exists()) {
            try {
                AudioFileFormat baseFileFormat = AudioSystem.getAudioFileFormat(file);
                if (baseFileFormat instanceof TAudioFileFormat) {
                    Map<?, ?> properties = baseFileFormat.properties();
                    String y = (String) properties.get("year");
                    if (y != null && y.trim().length() > 0) {
                        s.setYear(y);
                        s.setSaved(false);
                        changed = true;
                    }
                }
            } catch (Exception e) {
            }
        }
    }
    if (changed) {
        setSaved(false);
    }
    repaint();
}
 
開發者ID:SarutaSan72,項目名稱:Yass,代碼行數:40,代碼來源:YassSongList.java

示例4: getData

import javax.sound.sampled.AudioFileFormat; //導入方法依賴的package包/類
/**
 * Gets the data attribute of the YassUtils class
 *
 * @param s Description of the Parameter
 * @return The data value
 */
public static String[] getData(String s) {
    if (s == null) {
        return null;
    }
    File f = new File(s);
    if (!f.exists()) {
        return null;
    }
    try {
        AudioFileFormat baseFileFormat = AudioSystem.getAudioFileFormat(f);
        if (baseFileFormat instanceof TAudioFileFormat) {
            Map<?, ?> properties = baseFileFormat.properties();
            String artist = (String) properties.get("author");
            String title = (String) properties.get("title");

            String genre;
            s = f.getName();
            int i = s.indexOf(" - ");
            if (i >= 0) {
                if (artist == null || artist.trim().length() < 1) {
                    artist = s.substring(0, i).trim();
                }
                if (title == null || title.trim().length() < 1) {
                    title = s.substring(i + 3).trim();
                    i = title.indexOf("[");
                    if (i > 0) {
                        title = title.substring(0, i).trim();
                    }
                    i = title.lastIndexOf(".");
                    if (i > 0) {
                        title = title.substring(0, i).trim();
                    }
                }
            }

            genre = (String) properties.get("mp3.id3tag.genre");
            if (genre == null) {
                genre = "Unknown";
            }

            String data[] = new String[3];
            data[0] = title;
            data[1] = artist;
            data[2] = genre;
            return data;
        }
    } catch (Exception ignored) {
    }
    return null;
}
 
開發者ID:SarutaSan72,項目名稱:Yass,代碼行數:57,代碼來源:YassUtils.java


注:本文中的javax.sound.sampled.AudioFileFormat.properties方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。