00001 package i2bpro;
00002
00003 import i2bpro.Exceptions.PlayListException;
00004 import i2bpro.layer.Layer;
00005 import i2bpro.Exceptions.ErrorMsg;
00006 import java.io.BufferedReader;
00007 import java.io.FileNotFoundException;
00008 import java.io.FileReader;
00009 import java.io.IOException;
00010 import javax.swing.UIManager;
00011 import org.jaudiotagger.audio.exceptions.CannotReadException;
00012 import org.jaudiotagger.audio.exceptions.InvalidAudioFrameException;
00013 import org.jaudiotagger.audio.exceptions.ReadOnlyFileException;
00014 import org.jaudiotagger.tag.TagException;
00015
00016
00017
00035 public final class I2BPro
00036 {
00050 public static void main(String[] args) throws PlayListException,
00051 FileNotFoundException, IOException, CannotReadException,
00052 TagException, ReadOnlyFileException, InvalidAudioFrameException,
00053 Exception
00054 {
00055 UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
00056 String filename = null;
00057 if (args.length > 0)
00058 {
00059 for (int i=0; i<args.length; i++)
00060 {
00061
00062
00063
00064
00065
00066
00067 if (args[i].toLowerCase().equals("-pl"))
00068 {
00069 i++;
00070 try
00071 {
00072 filename = args[i];
00073 }
00074 catch (ArrayIndexOutOfBoundsException ex)
00075 {
00076 ErrorMsg.show("Zum Argument -pl fehlt die Pfadangabe "
00077 + "zur Playlist.");
00078 }
00079 } else {
00080 argHelp(args[i]);
00081 }
00082 }
00083 } else {
00084
00085
00086
00087
00088 BufferedReader f;
00089 String line;
00090 String[] tmp;
00091 try
00092 {
00093 f = new BufferedReader( new FileReader("i2bpro.cfg"));
00094
00095
00096
00097
00098 while((line = f.readLine()) != null)
00099 {
00100
00101 tmp = line.trim().toUpperCase().split("=");
00102
00103
00104
00105 if (tmp.length < 2) {
00106 cfgHelp();
00107 break;
00108 }
00109
00110
00111
00112
00113
00114 if (tmp[0].equals("PLAYLIST"))
00115 {
00116 filename = tmp[1];
00117 }
00118 }
00119 f.close();
00120 }
00121 catch (IOException e){}
00122 }
00123
00124
00125
00126
00127
00128
00129 if (filename == null)
00130 Layer.getInstance().run();
00131 else
00132 Layer.getInstance().run(filename);
00133 }
00134
00135
00136
00146 private static void argHelp(String arg)
00147 {
00148 String help = null;
00149 help = "Das Argument " + arg + "ist nicht zulässig. Zulässige ";
00150 help += "Argumente sind:\n\n";
00151 help += "Zulässige Argumente sind: \n";
00152 help += "-pl {Pfad zur Playlist} >> Angabe zur zu ladenden Playlist.";
00153 ErrorMsg.show(help);
00154 }
00155
00156
00157
00164 private static void cfgHelp()
00165 {
00166 String help = null;
00167 help = "Die Konfigurationdatei ist fehlerhaft.\n\n";
00168 help += "Zulässige Argumente sind:\n";
00169 help += "PlayList={Pfad zur Playlist} >> "
00170 + "Angabe zur zu ladenden Playlist.";
00171 ErrorMsg.show(help);
00172 }
00173 }