本文整理汇总了C#中IBackend.Add方法的典型用法代码示例。如果您正苦于以下问题:C# IBackend.Add方法的具体用法?C# IBackend.Add怎么用?C# IBackend.Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBackend
的用法示例。
在下文中一共展示了IBackend.Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _UpdateMP3FileInfo
///
/// 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 );
}
}