Пример #1
0
 /// <summary>
 /// Get track from the filename
 /// </summary>
 /// <param name="mintracklen">Min track length</param>
 /// <param name="maxtracklen">Max track length</param>
 /// <param name="filename">Filename from which to extract the requested info</param>
 /// <param name="proxy">Audio proxy to read tags</param>
 /// <returns>Track to be analyzed further / null if the track is not eligible</returns>
 private static Track GetTrack(int mintracklen, int maxtracklen, string filename, BassProxy proxy)
 {
     TAG_INFO tags = proxy.GetTagInfoFromFile(filename); //get file tags
     string artist, title;
     double duration;
     if (tags == null)
     {
         /*The song does not contain any tags*/
         artist = "Unknown";
         title = "Unknown";
         duration = 60;
     }
     else
     {
         /*The song contains related tags*/
         artist = tags.artist;
         title = tags.title;
         duration = tags.duration;
     }
     if (String.IsNullOrEmpty(artist)) /*assign a name to music files that don't have tags*/
         artist = "Unknown";
     if (String.IsNullOrEmpty(title)) /*assign a title to music files that don't have tags*/
         title = "Unknown";
     if (duration < mintracklen || duration > maxtracklen) /*check the duration of a music file*/
     {
         System.Diagnostics.Debug.WriteLine(String.Format("File {0} failed the duration validation. Duration: {1} [Min: {2}, Max: {3}]", filename, duration, mintracklen, maxtracklen) );
         return null;
     }
     Track track = new Track {Artist = artist, Title = title,
         TrackLength = duration, Path = Path.GetFullPath(filename)};
     return track;
 }