本文整理匯總了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();
}
示例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();
}
示例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();
}
示例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;
}