/// /// Updates the database info for a file. Assumes the file is an /// MP3 file. /// /// \todo Create a pluggable interface to extract the file info /// from various file types, not just mp3 /// void _UpdateMP3FileInfo( string path, IBackend engine ) { // Get ID3 tags from the file ID3v2 tag = new ID3v2( path, false ); if (!tag.isValid) { _Trace( "Note: No id3v2 tag found in file: '" + path + "'" ); return; } if ((null == tag.tit2) || (tag.tit2.Length == 0)) { // Match anything after the last forward/backslash string basename = Path.GetFileName( path ); Debug.Assert( null != basename, "All files have names!" ); Debug.Assert( basename.Length > 0, "All files have names!" ); _Trace( "Song title is empty, using file name: '" + basename + "'" ); tag.tit2 = basename; } string genre = tag.DefaultGenre; if (null == genre) genre = "unknown"; if (engine.EntryExists( path )) { engine.FileIsNotMissing( path ); } else { // Oh god, the noise, the noise! Just comment when something interesting // heppens, OK? // _Trace( "adding '" + path + "'" ); PlayableData data = new PlayableData(); data.filePath = path; if (tag.tpe1 == null) data.artist = ""; else data.artist = tag.tpe1; if (tag.talb == null) data.album = ""; else data.album = tag.talb; if (tag.tit2 == null) // no title, maybe check tit1 and tit3? data.title = ""; else data.title = tag.tit2; data.track = tag.trackIndex; data.genre = genre; data.lengthInSeconds = 0; // unknown, ID3 tag doesn't know engine.Add( data ); } }