/** * Create Default Tag * * @return */ //TODO might be better to instantiate classes such as Mp4File,FlacFile ecetera //TODO Generic tag is very misleading because soem of these formats cannot actually save the tag public Tag createDefaultTag() { if (SupportedFileFormat.FLAC.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.')))) { return new FlacTag(VorbisCommentTag.createNewTag(), new ArrayList<MetadataBlockDataPicture>()); } else if (SupportedFileFormat.OGG.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.')))) { return VorbisCommentTag.createNewTag(); } else if (SupportedFileFormat.MP4.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.')))) { return new Mp4Tag(); } else if (SupportedFileFormat.M4A.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.')))) { return new Mp4Tag(); } else if (SupportedFileFormat.M4P.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.')))) { return new Mp4Tag(); } else if (SupportedFileFormat.WAV.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.')))) { return new WavTag(); } else { throw new RuntimeException("Unable to create default tag for this file format"); } }
/** * <p>Check whether the given file meet the required conditions (supported by the library OR directory). * The File must also be readable and not hidden.</p> * * @param f The file to test * @return a boolean indicating if the file is accepted or not */ public boolean accept(File f) { if (f.isHidden() || !f.canRead()) { return false; } if (f.isDirectory()) { return allowDirectories; } String ext = Utils.getExtension(f); try { if (SupportedFileFormat.valueOf(ext.toUpperCase()) != null) { return true; } } catch (IllegalArgumentException iae) { //Not known enum value return false; } return false; } }
/** * Creates the readers and writers. */ private void prepareReadersAndWriters() { // Tag Readers readers.put(SupportedFileFormat.OGG.getFilesuffix(), new OggFileReader()); readers.put(SupportedFileFormat.FLAC.getFilesuffix(), new FlacFileReader()); readers.put(SupportedFileFormat.MP3.getFilesuffix(), new MP3FileReader()); readers.put(SupportedFileFormat.MP4.getFilesuffix(), new Mp4FileReader()); readers.put(SupportedFileFormat.M4A.getFilesuffix(), new Mp4FileReader()); readers.put(SupportedFileFormat.M4P.getFilesuffix(), new Mp4FileReader()); readers.put(SupportedFileFormat.M4B.getFilesuffix(), new Mp4FileReader()); readers.put(SupportedFileFormat.WAV.getFilesuffix(), new WavFileReader()); // Tag Writers writers.put(SupportedFileFormat.OGG.getFilesuffix(), new OggFileWriter()); writers.put(SupportedFileFormat.FLAC.getFilesuffix(), new FlacFileWriter()); writers.put(SupportedFileFormat.MP3.getFilesuffix(), new MP3FileWriter()); writers.put(SupportedFileFormat.MP4.getFilesuffix(), new Mp4FileWriter()); writers.put(SupportedFileFormat.M4A.getFilesuffix(), new Mp4FileWriter()); writers.put(SupportedFileFormat.M4P.getFilesuffix(), new Mp4FileWriter()); writers.put(SupportedFileFormat.M4B.getFilesuffix(), new Mp4FileWriter()); writers.put(SupportedFileFormat.WAV.getFilesuffix(), new WavFileWriter()); // Register modificationHandler for (AudioFileWriter curr : writers.values()) { curr.setAudioFileModificationListener(this.modificationHandler); } }
if (SupportedFileFormat.valueOf(ext.toUpperCase()) != null)
readers.put(SupportedFileFormat.OGG.getFilesuffix(), new OggFileReader()); readers.put(SupportedFileFormat.FLAC.getFilesuffix(),new FlacFileReader()); readers.put(SupportedFileFormat.MP3.getFilesuffix(), new MP3FileReader()); readers.put(SupportedFileFormat.MP4.getFilesuffix(), new Mp4FileReader()); readers.put(SupportedFileFormat.M4A.getFilesuffix(), new Mp4FileReader()); readers.put(SupportedFileFormat.M4P.getFilesuffix(), new Mp4FileReader()); readers.put(SupportedFileFormat.M4B.getFilesuffix(), new Mp4FileReader()); readers.put(SupportedFileFormat.WAV.getFilesuffix(), new WavFileReader()); readers.put(SupportedFileFormat.WMA.getFilesuffix(), new AsfFileReader()); final RealFileReader realReader = new RealFileReader(); readers.put(SupportedFileFormat.RA.getFilesuffix(), realReader); readers.put(SupportedFileFormat.RM.getFilesuffix(), realReader); writers.put(SupportedFileFormat.OGG.getFilesuffix(), new OggFileWriter()); writers.put(SupportedFileFormat.FLAC.getFilesuffix(), new FlacFileWriter()); writers.put(SupportedFileFormat.MP3.getFilesuffix(), new MP3FileWriter()); writers.put(SupportedFileFormat.MP4.getFilesuffix(), new Mp4FileWriter()); writers.put(SupportedFileFormat.M4A.getFilesuffix(), new Mp4FileWriter()); writers.put(SupportedFileFormat.M4P.getFilesuffix(), new Mp4FileWriter()); writers.put(SupportedFileFormat.M4B.getFilesuffix(), new Mp4FileWriter()); writers.put(SupportedFileFormat.WAV.getFilesuffix(), new WavFileWriter()); writers.put(SupportedFileFormat.WMA.getFilesuffix(), new AsfFileWriter());
if (SupportedFileFormat.valueOf(ext.toUpperCase()) != null)
readers.put(SupportedFileFormat.OGG.getFilesuffix(), new OggFileReader()); readers.put(SupportedFileFormat.FLAC.getFilesuffix(),new FlacFileReader()); readers.put(SupportedFileFormat.MP3.getFilesuffix(), new MP3FileReader()); readers.put(SupportedFileFormat.MP4.getFilesuffix(), new Mp4FileReader()); readers.put(SupportedFileFormat.M4A.getFilesuffix(), new Mp4FileReader()); readers.put(SupportedFileFormat.M4P.getFilesuffix(), new Mp4FileReader()); readers.put(SupportedFileFormat.M4B.getFilesuffix(), new Mp4FileReader()); readers.put(SupportedFileFormat.WAV.getFilesuffix(), new WavFileReader()); readers.put(SupportedFileFormat.WMA.getFilesuffix(), new AsfFileReader()); readers.put(SupportedFileFormat.AIF.getFilesuffix(), new AiffFileReader()); readers.put(SupportedFileFormat.AIFC.getFilesuffix(), new AiffFileReader()); readers.put(SupportedFileFormat.AIFF.getFilesuffix(), new AiffFileReader()); readers.put(SupportedFileFormat.DSF.getFilesuffix(), new DsfFileReader()); final RealFileReader realReader = new RealFileReader(); readers.put(SupportedFileFormat.RA.getFilesuffix(), realReader); readers.put(SupportedFileFormat.RM.getFilesuffix(), realReader); writers.put(SupportedFileFormat.OGG.getFilesuffix(), new OggFileWriter()); writers.put(SupportedFileFormat.FLAC.getFilesuffix(), new FlacFileWriter()); writers.put(SupportedFileFormat.MP3.getFilesuffix(), new MP3FileWriter()); writers.put(SupportedFileFormat.MP4.getFilesuffix(), new Mp4FileWriter()); writers.put(SupportedFileFormat.M4A.getFilesuffix(), new Mp4FileWriter()); writers.put(SupportedFileFormat.M4P.getFilesuffix(), new Mp4FileWriter()); writers.put(SupportedFileFormat.M4B.getFilesuffix(), new Mp4FileWriter()); writers.put(SupportedFileFormat.WAV.getFilesuffix(), new WavFileWriter()); writers.put(SupportedFileFormat.WMA.getFilesuffix(), new AsfFileWriter()); writers.put(SupportedFileFormat.AIF.getFilesuffix(), new AiffFileWriter()); writers.put(SupportedFileFormat.AIFC.getFilesuffix(), new AiffFileWriter()); writers.put(SupportedFileFormat.AIFF.getFilesuffix(), new AiffFileWriter());
if(SupportedFileFormat.FLAC.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.')))) else if(SupportedFileFormat.OGG.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.')))) else if(SupportedFileFormat.MP4.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.')))) else if(SupportedFileFormat.M4A.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.')))) else if(SupportedFileFormat.M4P.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.')))) else if(SupportedFileFormat.WMA.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.')))) else if(SupportedFileFormat.WAV.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.')))) else if(SupportedFileFormat.RA.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.')))) else if(SupportedFileFormat.RM.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.'))))
if(SupportedFileFormat.FLAC.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.') + 1))) else if(SupportedFileFormat.OGG.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.') + 1))) else if(SupportedFileFormat.MP4.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.') + 1))) else if(SupportedFileFormat.M4A.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.') + 1))) else if(SupportedFileFormat.M4P.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.') + 1))) else if(SupportedFileFormat.WMA.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.') + 1))) else if(SupportedFileFormat.WAV.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.') + 1))) else if(SupportedFileFormat.RA.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.') + 1))) else if(SupportedFileFormat.RM.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.') + 1))) else if(SupportedFileFormat.AIF.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.') + 1))) else if(SupportedFileFormat.AIFC.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.') + 1))) else if(SupportedFileFormat.AIFF.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.') + 1))) else if(SupportedFileFormat.DSF.getFilesuffix().equals(file.getName().substring(file.getName().lastIndexOf('.') + 1)))