/// <summary> /// Gets the appropriate metadata reader for a given file / physical data reader /// </summary> /// <param name="path">Path of the file</param> /// <param name="theDataReader">AudioDataReader produced for this file</param> /// <returns>Metadata reader able to give metadata info for this file (or the dummy reader if the format is unknown)</returns> public IMetadataReader GetMetaReader(String path, IAudioReader theDataReader) { IMetadataReader theMetaReader = null; // Step 1 : The physical reader may have already parsed the metadata for (int i=0; i<TAG_TYPE_COUNT; i++) { if ( (TAG_ID3V1 == tagPriority[i]) && (theDataReader.ID3v1.Exists) ) { theMetaReader = theDataReader.ID3v1; break; } if ( (TAG_ID3V2 == tagPriority[i]) && (theDataReader.ID3v2.Exists) ) { theMetaReader = theDataReader.ID3v2; break; } if ( (TAG_APE == tagPriority[i]) && (theDataReader.APEtag.Exists) ) { theMetaReader = theDataReader.APEtag; break; } } // Step 2 : Nothing found in step 1 -> considerate specific tagging (data+meta file formats) if (null == theMetaReader) { //# improve something here /* if (theDataReader is BinaryLogic.TOggVorbis) { BinaryLogic.TOggVorbis theVorbis = new BinaryLogic.TOggVorbis(); theVorbis.ReadFromFile(path); theMetaReader = theVorbis; } if (theDataReader is BinaryLogic.TWMAfile) { BinaryLogic.TWMAfile theWMA = new BinaryLogic.TWMAfile(); theWMA.ReadFromFile(path); theMetaReader = theWMA; } if (theDataReader is BinaryLogic.TFLACFile) { BinaryLogic.TFLACFile theFLAC = new BinaryLogic.TFLACFile(); theFLAC.ReadFromFile(path); theMetaReader = theFLAC; } if (theDataReader is BinaryLogic.TPSFFile) { BinaryLogic.TPSFFile thePSF = new BinaryLogic.TPSFFile(); thePSF.ReadFromFile(path); theMetaReader = thePSF; } if (theDataReader is BinaryLogic.TSPCFile) { BinaryLogic.TSPCFile theSPC = new BinaryLogic.TSPCFile(); theSPC.ReadFromFile(path); theMetaReader = theSPC; }*/ if ((theDataReader is BinaryLogic.TOggVorbis) || (theDataReader is BinaryLogic.TWMAfile) || (theDataReader is BinaryLogic.TFLACFile) || (theDataReader is BinaryLogic.TPSFFile) || (theDataReader is BinaryLogic.TSPCFile) ) { theMetaReader = (IMetadataReader)theDataReader; // Boorish but correct cast } } // Step 3 : default (no tagging at all - provides the dummy reader) if (null == theMetaReader) theMetaReader = new BinaryLogic.DummyTag(); return theMetaReader; }
/// <summary> /// Gets the appropriate metadata reader for a given file / physical data reader /// </summary> /// <param name="path">Path of the file</param> /// <param name="theDataReader">AudioDataReader produced for this file</param> /// <returns>Metadata reader able to give metadata info for this file (or the dummy reader if the format is unknown)</returns> public IMetadataReader GetMetaReader(String path, IAudioReader theDataReader) { IMetadataReader theMetaReader = null; // Step 1 : The physical reader may have already parsed the metadata for (int i = 0; i < TAG_TYPE_COUNT; i++) { if ((TAG_ID3V1 == tagPriority[i]) && (theDataReader.ID3v1.Exists)) { theMetaReader = theDataReader.ID3v1; break; } if ((TAG_ID3V2 == tagPriority[i]) && (theDataReader.ID3v2.Exists)) { theMetaReader = theDataReader.ID3v2; break; } if ((TAG_APE == tagPriority[i]) && (theDataReader.APEtag.Exists)) { theMetaReader = theDataReader.APEtag; break; } } // Step 2 : Nothing found in step 1 -> considerate specific tagging (data+meta file formats) if (null == theMetaReader) { //# improve something here /* * if (theDataReader is BinaryLogic.TOggVorbis) * { * BinaryLogic.TOggVorbis theVorbis = new BinaryLogic.TOggVorbis(); * theVorbis.ReadFromFile(path); * theMetaReader = theVorbis; * } * * if (theDataReader is BinaryLogic.TWMAfile) * { * BinaryLogic.TWMAfile theWMA = new BinaryLogic.TWMAfile(); * theWMA.ReadFromFile(path); * theMetaReader = theWMA; * } * * if (theDataReader is BinaryLogic.TFLACFile) * { * BinaryLogic.TFLACFile theFLAC = new BinaryLogic.TFLACFile(); * theFLAC.ReadFromFile(path); * theMetaReader = theFLAC; * } * * if (theDataReader is BinaryLogic.TPSFFile) * { * BinaryLogic.TPSFFile thePSF = new BinaryLogic.TPSFFile(); * thePSF.ReadFromFile(path); * theMetaReader = thePSF; * } * * if (theDataReader is BinaryLogic.TSPCFile) * { * BinaryLogic.TSPCFile theSPC = new BinaryLogic.TSPCFile(); * theSPC.ReadFromFile(path); * theMetaReader = theSPC; * }*/ if ((theDataReader is BinaryLogic.TOggVorbis) || (theDataReader is BinaryLogic.TWMAfile) || (theDataReader is BinaryLogic.TFLACFile) || (theDataReader is BinaryLogic.TPSFFile) || (theDataReader is BinaryLogic.TSPCFile)) { theMetaReader = (IMetadataReader)theDataReader; // Boorish but correct cast } } // Step 3 : default (no tagging at all - provides the dummy reader) if (null == theMetaReader) { theMetaReader = new BinaryLogic.DummyTag(); } return(theMetaReader); }