Update of /cvsroot/javaamp/javaamp/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6516/src Modified Files: EQLabel.java FileInformationDialog.java GetFileInfoThread.java JavaAmp.java PlayQueue.java PlaylistDialog.java Added Files: JavaAmpToolkit.java Log Message: FileInformationDialog and file information retrieving improved, JavaAmpToolkit Index: JavaAmp.java =================================================================== RCS file: /cvsroot/javaamp/javaamp/src/JavaAmp.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- JavaAmp.java 25 Feb 2006 16:49:59 -0000 1.8 +++ JavaAmp.java 28 Feb 2006 16:08:13 -0000 1.9 @@ -41,12 +41,19 @@ setVisible(true); playDialog = new PlayDialog(this); - playlistDialog = new PlaylistDialog(this); equalizerDialog = new EqualizerDialog(this); + playlistDialog = new PlaylistDialog(this); + Dimension si = getToolkit().getScreenSize(); + Insets in = getToolkit().getScreenInsets(getGraphicsConfiguration()); + int x = (si.width + in.left - in.right - 275) / 2; + int y = (si.height + in.top - in.bottom - 345) / 2; + playDialog.setLocation(x, y); + equalizerDialog.setLocation(x, y + 115); + playlistDialog.setLocation(x, y + 230); playDialog.setVisible(true); playDialog.splSpectrum.start(); - playlistDialog.setVisible(true); equalizerDialog.setVisible(true); + playlistDialog.setVisible(true); } public static void error(Exception e) { @@ -82,7 +89,6 @@ "com.jgoodies.looks.plastic.Plastic3DLookAndFeel"); } catch(Exception e) { - warning(e); } try { new JavaAmp(); Index: PlayQueue.java =================================================================== RCS file: /cvsroot/javaamp/javaamp/src/PlayQueue.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- PlayQueue.java 26 Feb 2006 13:38:29 -0000 1.13 +++ PlayQueue.java 28 Feb 2006 16:08:13 -0000 1.14 @@ -63,34 +63,11 @@ stream = FSound.FSOUND_Stream_Open(fieCurrent.file.toString(), FSound.FSOUND_MPEGACCURATE, 0, 0); if(stream == null) { - try { - InputStream in = new FileInputStream(fieCurrent.file); - byte[] start = { 0x52, 0x49, 0x46, 0x46, 0x24, 0x00, - 0x00, 0x00, 0x43, 0x44, 0x44, 0x41, 0x66, 0x6D, - 0x74, 0x20 }; - for(i = 0; i < 16; i++) - if(in.read() != start[i]) - throw new Exception(); - in.skip(6); - int nr = in.read() & 0xFF; - nr |= (in.read() & 0xFF) >> 8; - nr--; - in.close(); - String f = fieCurrent.file.toString(); - int ind = f.indexOf(':'); - if(ind <= 0) - throw new Exception(); - f = f.substring(0, ind + 1); - stream = FSound.FSOUND_Stream_Open(f, 0, 0, 0); - if(stream == null) - throw new Exception(); - if(FSound.FSOUND_Stream_SetSubStream(stream, nr) != 1) - throw new Exception(); - error = false; - } - catch(Exception e) { + stream = JavaAmpToolkit.openCDStream(fieCurrent); + if(stream == null) error = true; - } + else + error = false; } else error = false; Index: EQLabel.java =================================================================== RCS file: /cvsroot/javaamp/javaamp/src/EQLabel.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- EQLabel.java 25 Feb 2006 16:49:59 -0000 1.6 +++ EQLabel.java 28 Feb 2006 16:08:13 -0000 1.7 @@ -51,7 +51,7 @@ offg.setColor(Color.LIGHT_GRAY); offg.drawLine(i * 24 - 1, 0, i * 24 - 1, 65); } - offg.setColor(Color.DARK_GRAY); + offg.setColor(Color.LIGHT_GRAY); offg.fillRect(0, 63 - owner.equalizerDialog.sliPre.getValue(), 239, 3); offg.setColor(Color.BLACK); for(int i = 0; i < 10; i++) { Index: PlaylistDialog.java =================================================================== RCS file: /cvsroot/javaamp/javaamp/src/PlaylistDialog.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- PlaylistDialog.java 26 Feb 2006 16:16:12 -0000 1.20 +++ PlaylistDialog.java 28 Feb 2006 16:08:13 -0000 1.21 @@ -574,13 +574,6 @@ gfit.start(); } - public final static String getDuration(int d) { - String sec = "" + d % 60; - while(sec.length() < 2) - sec = '0' + sec; - return (d / 60) + ":" + sec; - } - public void addFiles() { owner.fchChooser.setMultiSelectionEnabled(true); owner.fchChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); @@ -725,7 +718,7 @@ entry.update = true; } if(len >= 0) { - entry.name += '|' + getDuration(len); + entry.name += '|' + JavaAmpToolkit.getDuration(len); entry.update = true; } entries.add(entry); @@ -738,7 +731,7 @@ entry.update = true; } if(len >= 0) { - entry.name += '|' + getDuration(len); + entry.name += '|' + JavaAmpToolkit.getDuration(len); entry.update = true; } entries.add(entry); @@ -769,7 +762,7 @@ int len = Integer.parseInt(s); if(len >= 0) { FileEntry entry = entries.get(entries.size() - 1); - entry.name += '|' + getDuration(len); + entry.name += '|' + JavaAmpToolkit.getDuration(len); entries.set(entries.size() - 1, entry); } } --- NEW FILE: JavaAmpToolkit.java --- import java.io.*; import org.lwjgl.fmod3.*; public class JavaAmpToolkit { public final static String getDuration(int d) { String sec = "" + d % 60; while(sec.length() < 2) sec = '0' + sec; return (d / 60) + ":" + sec; } public final static FSoundStream openCDStream(FileEntry entry) { if(entry.type != FileEntry.TYPE_FILE) return null; FSoundStream str = null; try { InputStream in = new FileInputStream(entry.file); byte[] start = { 0x52, 0x49, 0x46, 0x46, 0x24, 0x00, 0x00, 0x00, 0x43, 0x44, 0x44, 0x41, 0x66, 0x6D, 0x74, 0x20 }; for(int i = 0; i < 16; i++) if(in.read() != start[i]) throw new Exception(); in.skip(6); int nr = in.read() & 0xFF; nr |= (in.read() & 0xFF) >> 8; in.close(); nr--; String f = entry.file.toString(); int ind = f.indexOf(':'); if(ind <= 0) throw new Exception(); f = f.substring(0, ind + 1); str = FSound.FSOUND_Stream_Open(f, 0, 0, 0); if(str == null) throw new Exception(); if(FSound.FSOUND_Stream_SetSubStream(str, nr) != 1) throw new Exception(); } catch(Exception e) { if(str != null) FSound.FSOUND_Stream_Close(str); return null; } return str; } } Index: FileInformationDialog.java =================================================================== RCS file: /cvsroot/javaamp/javaamp/src/FileInformationDialog.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FileInformationDialog.java 28 Feb 2006 12:33:08 -0000 1.4 +++ FileInformationDialog.java 28 Feb 2006 16:08:13 -0000 1.5 @@ -56,8 +56,6 @@ tapType = new JTabbedPane(); tapType.setBounds(10, 40, 470, 320); - for(int i = 0; i < containers.length; i++) - tapType.addTab(descriptions[i], containers[i]); cntContainer.add(tfdFile); cntContainer.add(tapType); @@ -98,6 +96,10 @@ tag.getValueAsString() }); } } + tapType.removeAll(); + for(int i = 0; i < containers.length; i++) + if(tables[i].getModel().getRowCount() > 0) + tapType.add(descriptions[i], containers[i]); return true; } } Index: GetFileInfoThread.java =================================================================== RCS file: /cvsroot/javaamp/javaamp/src/GetFileInfoThread.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- GetFileInfoThread.java 25 Feb 2006 14:10:48 -0000 1.5 +++ GetFileInfoThread.java 28 Feb 2006 16:08:13 -0000 1.6 @@ -1,5 +1,4 @@ import java.io.*; -import java.nio.*; import javax.swing.*; import org.lwjgl.fmod3.*; @@ -7,7 +6,6 @@ JavaAmp owner; boolean running; - private IntBuffer num; static int[] ttype = new int[] { FSound.FSOUND_TAGFIELD_ID3V2, FSound.FSOUND_TAGFIELD_ID3V1, FSound.FSOUND_TAGFIELD_VORBISCOMMENT, FSound.FSOUND_TAGFIELD_ASF, @@ -17,9 +15,6 @@ public GetFileInfoThread(JavaAmp o) { owner = o; running = true; - ByteBuffer tmp = ByteBuffer.allocateDirect(4); - tmp.order(ByteOrder.nativeOrder()); - num = tmp.asIntBuffer(); } public void run() { @@ -58,8 +53,13 @@ else if(entry.type == FileEntry.TYPE_URL) str = FSound.FSOUND_Stream_Open(entry.url.toString(), mode, 0, 0); - // TODO: CDs - if(entry.type != FileEntry.TYPE_CD && str == null) { + if(str != null) { + getInfo(str, entry); + FSound.FSOUND_Stream_Close(str); + return; + } + // TODO: Informationen von richtigen CDs lesen (nicht CDA) + if(entry.type != FileEntry.TYPE_CD) { if(entry.type == FileEntry.TYPE_FILE) mod = FMusic.FMUSIC_LoadSong(entry.file.toString()); else if(entry.type == FileEntry.TYPE_URL) @@ -67,50 +67,17 @@ if(mod != null) { getInfo(mod, entry); FMusic.FMUSIC_FreeSong(mod); + return; } } - if(str == null && mod == null && entry.type == FileEntry.TYPE_FILE) { - try { - InputStream in = new FileInputStream(entry.file); - byte[] start = { 0x52, 0x49, 0x46, 0x46, 0x24, 0x00, 0x00, 0x00, - 0x43, 0x44, 0x44, 0x41, 0x66, 0x6D, 0x74, 0x20 }; - for(int i = 0; i < 16; i++) - if(in.read() != start[i]) - throw new Exception(); - in.skip(6); - int nr = in.read() & 0xFF; - nr |= (in.read() & 0xFF) >> 8; - in.close(); - nr--; - String f = entry.file.toString(); - int ind = f.indexOf(':'); - if(ind <= 0) - throw new Exception(); - f = f.substring(0, ind + 1); - str = FSound.FSOUND_Stream_Open(f, 0, 0, 0); - if(str == null) - throw new Exception(); - if(FSound.FSOUND_Stream_SetSubStream(str, nr) != 1) - throw new Exception(); - StringBuilder info = new StringBuilder(entry.file.getName()); - int i = info.indexOf("."); - if(i >= 0) - info = new StringBuilder(info.substring(0, i)); - info.append('|'); - info.append(PlaylistDialog.getDuration( - FSound.FSOUND_Stream_GetLengthMs(str) / 1000)); - entry.name = info.toString(); - entry.update = true; - } - catch(Exception e) { - } - if(str != null) + if(entry.type == FileEntry.TYPE_FILE) { + str = JavaAmpToolkit.openCDStream(entry); + if(str != null) { + getInfo(str, entry); FSound.FSOUND_Stream_Close(str); + } return; } - getInfo(str, entry); - if(str != null) - FSound.FSOUND_Stream_Close(str); } public final static void getInfo(FSoundStream stream, FileEntry entry) { @@ -124,28 +91,30 @@ break; } } - info.append(" - "); - for(int val : ttype) { - FSoundTagField fld = new FSoundTagField(val, "TITLE"); - if(FSound.FSOUND_Stream_FindTagField(stream, fld)) { - info.append(fld.getValueAsString()); - if(!flag) + if(!flag) { + flag = true; + info.append(" - "); + for(int val : ttype) { + FSoundTagField fld = new FSoundTagField(val, "TITLE"); + if(FSound.FSOUND_Stream_FindTagField(stream, fld)) { + info.append(fld.getValueAsString()); flag = false; - break; + break; + } } } if(flag) { if(entry.type == FileEntry.TYPE_FILE) { info = new StringBuilder(entry.file.getName()); - int ind = info.indexOf("."); - if(ind >= 0) + int ind = info.lastIndexOf("."); + if(ind > 0) info = new StringBuilder(info.substring(0, ind)); } else if(entry.type == FileEntry.TYPE_URL) info = new StringBuilder(entry.url.toString()); } info.append('|'); - info.append(PlaylistDialog.getDuration(FSound.FSOUND_Stream_GetLengthMs( + info.append(JavaAmpToolkit.getDuration(FSound.FSOUND_Stream_GetLengthMs( stream) / 1000)); entry.name = info.toString(); entry.update = true; @@ -155,6 +124,16 @@ String info = FMusic.FMUSIC_GetName(module); if(info != null) entry.name = info; + else { + if(entry.type == FileEntry.TYPE_FILE) { + entry.name = entry.file.getName(); + int ind = entry.name.lastIndexOf('.'); + if(ind > 0) + entry.name = entry.name.substring(0, ind); + } + else + entry.name = entry.url.toString(); + } entry.update = true; } } \ No newline at end of file |