当前位置: 首页>>代码示例>>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;未经允许,请勿转载。