本文整理汇总了C#中TagLib类的典型用法代码示例。如果您正苦于以下问题:C# TagLib类的具体用法?C# TagLib怎么用?C# TagLib使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TagLib类属于命名空间,在下文中一共展示了TagLib类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Tag
public Tag(TagLib.NonContainer.File file)
{
this.start_tag = new TagLib.NonContainer.StartTag(file);
this.end_tag = new TagLib.NonContainer.EndTag(file);
base.AddTag(this.start_tag);
base.AddTag(this.end_tag);
}
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:7,代码来源:Tag.cs
示例2: Get
public static AttachedPictureFrame Get(TagLib.Id3v2.Tag tag, string description, PictureType type, bool create)
{
AttachedPictureFrame frame;
IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.APIC).GetEnumerator();
try
{
while (enumerator.MoveNext())
{
Frame current = enumerator.Current;
frame = current as AttachedPictureFrame;
if (((frame != null) && ((description == null) || (frame.Description == description))) && ((type == PictureType.Other) || (frame.Type == type)))
{
return frame;
}
}
}
finally
{
if (enumerator == null)
{
}
enumerator.Dispose();
}
if (!create)
{
return null;
}
frame = new AttachedPictureFrame {
Description = description,
Type = type
};
tag.AddFrame(frame);
return frame;
}
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:34,代码来源:AttachedPictureFrame.cs
示例3: GetPreferred
public static TermsOfUseFrame GetPreferred(TagLib.Id3v2.Tag tag, string language)
{
TermsOfUseFrame frame = null;
IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.USER).GetEnumerator();
try
{
while (enumerator.MoveNext())
{
Frame current = enumerator.Current;
TermsOfUseFrame frame3 = current as TermsOfUseFrame;
if (frame3 != null)
{
if (frame3.Language == language)
{
return frame3;
}
if (frame == null)
{
frame = frame3;
}
}
}
}
finally
{
if (enumerator == null)
{
}
enumerator.Dispose();
}
return frame;
}
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:32,代码来源:TermsOfUseFrame.cs
示例4: Get
public static TermsOfUseFrame Get(TagLib.Id3v2.Tag tag, string language, bool create)
{
IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.USER).GetEnumerator();
try
{
while (enumerator.MoveNext())
{
Frame current = enumerator.Current;
TermsOfUseFrame frame2 = current as TermsOfUseFrame;
if ((frame2 != null) && ((language == null) || (language == frame2.Language)))
{
return frame2;
}
}
}
finally
{
if (enumerator == null)
{
}
enumerator.Dispose();
}
if (!create)
{
return null;
}
TermsOfUseFrame frame3 = new TermsOfUseFrame(language);
tag.AddFrame(frame3);
return frame3;
}
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:30,代码来源:TermsOfUseFrame.cs
示例5: SaveXmpSidecar
public static bool SaveXmpSidecar(this TagLib.Image.File file, TagLib.File.IFileAbstraction resource)
{
var xmp_tag = file.GetTag (TagLib.TagTypes.XMP, false) as XmpTag;
if (xmp_tag == null) {
// TODO: Delete File
return true;
}
var xmp = xmp_tag.Render ();
try {
using (var stream = resource.WriteStream) {
stream.SetLength (0);
using (var writer = new StreamWriter (stream)) {
writer.Write (xmp);
}
resource.CloseStream (stream);
}
} catch (Exception e) {
Log.DebugFormat ("Sidecar cannot be saved: {0}", resource.Name);
Log.DebugException (e);
return false;
}
return true;
}
开发者ID:nathansamson,项目名称:F-Spot-Album-Exporter,代码行数:26,代码来源:SidecarXmpExtensions.cs
示例6: OverwriteSequenceNumbers
public static void OverwriteSequenceNumbers(TagLib.Ogg.File file, long position, IDictionary<uint, int> shiftTable)
{
if (file == null)
{
throw new ArgumentNullException("file");
}
if (shiftTable == null)
{
throw new ArgumentNullException("shiftTable");
}
bool flag = true;
IEnumerator<KeyValuePair<uint, int>> enumerator = shiftTable.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
KeyValuePair<uint, int> current = enumerator.Current;
if (current.Value != 0)
{
flag = false;
goto Label_0065;
}
}
}
finally
{
if (enumerator == null)
{
}
enumerator.Dispose();
}
Label_0065:
if (flag)
{
return;
}
while (position < (file.Length - 0x1bL))
{
PageHeader header = new PageHeader(file, position);
int length = (int) (header.Size + header.DataSize);
if (shiftTable.ContainsKey(header.StreamSerialNumber) && (shiftTable[header.StreamSerialNumber] != 0))
{
file.Seek(position);
ByteVector vector = file.ReadBlock(length);
ByteVector data = ByteVector.FromUInt(header.PageSequenceNumber + ((uint) ((long) shiftTable[header.StreamSerialNumber])), false);
for (int i = 0x12; i < 0x16; i++)
{
vector[i] = data[i - 0x12];
}
for (int j = 0x16; j < 0x1a; j++)
{
vector[j] = 0;
}
data.Add(ByteVector.FromUInt(vector.Checksum, false));
file.Seek(position + 0x12L);
file.WriteBlock(data);
}
position += length;
}
}
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:60,代码来源:Page.cs
示例7: AviHeaderList
/// <summary>
/// Constructs and initializes a new instance of <see
/// cref="AviHeaderList" /> by reading the contents of a raw
/// RIFF list from a specified position in a <see
/// cref="TagLib.File"/>.
/// </summary>
/// <param name="file">
/// A <see cref="TagLib.File" /> object containing the file
/// from which the contents of the new instance is to be
/// read.
/// </param>
/// <param name="position">
/// A <see cref="long" /> value specify at what position to
/// read the list.
/// </param>
/// <param name="length">
/// A <see cref="int" /> value specifying the number of bytes
/// to read.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="file" /> is <see langword="null" />.
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
/// <paramref name="position" /> is less than zero or greater
/// than the size of the file.
/// </exception>
/// <exception cref="CorruptFileException">
/// The list does not contain an AVI header or the AVI header
/// is the wrong length.
/// </exception>
public AviHeaderList (TagLib.File file, long position,
int length)
{
if (file == null)
throw new ArgumentNullException ("file");
if (length < 0)
throw new ArgumentOutOfRangeException (
"length");
if (position < 0 || position > file.Length - length)
throw new ArgumentOutOfRangeException (
"position");
List list = new List (file, position, length);
if (!list.ContainsKey ("avih"))
throw new CorruptFileException (
"Avi header not found.");
ByteVector header_data = list ["avih"][0];
if (header_data.Count != 0x38)
throw new CorruptFileException (
"Invalid header length.");
header = new AviHeader (header_data, 0);
foreach (ByteVector list_data in list ["LIST"])
if (list_data.StartsWith ("strl"))
codecs.Add (AviStream
.ParseStreamList (list_data)
.Codec);
}
开发者ID:JohnThomson,项目名称:taglib-sharp,代码行数:63,代码来源:AviHeaderList.cs
示例8: Get
public static MusicCdIdentifierFrame Get(TagLib.Id3v2.Tag tag, bool create)
{
MusicCdIdentifierFrame frame;
IEnumerator<Frame> enumerator = tag.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
Frame current = enumerator.Current;
frame = current as MusicCdIdentifierFrame;
if (frame != null)
{
return frame;
}
}
}
finally
{
if (enumerator == null)
{
}
enumerator.Dispose();
}
if (!create)
{
return null;
}
frame = new MusicCdIdentifierFrame();
tag.AddFrame(frame);
return frame;
}
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:31,代码来源:MusicCdIdentifierFrame.cs
示例9: Song
public Song(TagLib.File file, string path)
{
tagFile = file;
Path = path;
int temp = path.LastIndexOf('\\');
FileName = path.Substring(temp+1, path.Length - temp - 1);
}
开发者ID:stolksdorf,项目名称:taggy,代码行数:7,代码来源:Song.cs
示例10: AppleAdditionalInfoBox
/// <summary>
/// Constructs and initializes a new instance of <see
/// cref="AppleAdditionalInfoBox" /> with a provided header
/// and handler by reading the contents from a specified
/// file.
/// </summary>
/// <param name="header">
/// A <see cref="BoxHeader" /> object containing the header
/// to use for the new instance.
/// </param>
/// <param name="file">
/// A <see cref="TagLib.File" /> object to read the contents
/// of the box from.
/// </param>
/// <param name="handler">
/// A <see cref="IsoHandlerBox" /> object containing the
/// handler that applies to the new instance.
/// </param>
/// <exception cref="ArgumentNullException">
/// <paramref name="file" /> is <see langword="null" />.
/// </exception>
public AppleAdditionalInfoBox(BoxHeader header, TagLib.File file, IsoHandlerBox handler)
: base(header, file, handler)
{
// We do not care what is in this custom data section
// see: https://developer.apple.com/library/mac/#documentation/QuickTime/QTFF/QTFFChap2/qtff2.html
Data = file.ReadBlock(DataSize > 0 ? DataSize : 0); ;
}
开发者ID:samueldjack,项目名称:taglib-sharp,代码行数:28,代码来源:AppleAdditionalInfoBox.cs
示例11: getAvatarImg
public static void getAvatarImg(ref TagLib.File tagFile, ref JsonPoco.Track song)
{
//download user profile avatar image
string avatarFilepath = Path.GetTempFileName();
string highResAvatar_url = song.user.avatar_url.Replace("large.jpg", "t500x500.jpg");
for (int attempts = 0; attempts < 5; attempts++)
{
try
{
using (WebClient web = new WebClient())
{
web.DownloadFile(highResAvatar_url, avatarFilepath);
}
TagLib.Picture artwork = new TagLib.Picture(avatarFilepath);
artwork.Type = TagLib.PictureType.FrontCover;
tagFile.Tag.Pictures = new[] { artwork };
break;
}
catch (Exception e)
{
Debug.WriteLine(e);
}
System.Threading.Thread.Sleep(50); // Pause 50ms before new attempt
}
if (avatarFilepath != null && File.Exists(avatarFilepath))
{
File.Delete(avatarFilepath);
}
}
开发者ID:Tomiscout,项目名称:SoundCloud-Playlist-Sync,代码行数:31,代码来源:metadataTagging.cs
示例12: Get
public static UniqueFileIdentifierFrame Get(TagLib.Id3v2.Tag tag, string owner, bool create)
{
UniqueFileIdentifierFrame frame;
IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.UFID).GetEnumerator();
try
{
while (enumerator.MoveNext())
{
Frame current = enumerator.Current;
frame = current as UniqueFileIdentifierFrame;
if ((frame != null) && (frame.Owner == owner))
{
return frame;
}
}
}
finally
{
if (enumerator == null)
{
}
enumerator.Dispose();
}
if (!create)
{
return null;
}
frame = new UniqueFileIdentifierFrame(owner, null);
tag.AddFrame(frame);
return frame;
}
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:31,代码来源:UniqueFileIdentifierFrame.cs
示例13: HeaderExtensionObject
public HeaderExtensionObject(TagLib.Asf.File file, long position) : base(file, position)
{
this.children = new List<TagLib.Asf.Object>();
if (!base.Guid.Equals(TagLib.Asf.Guid.AsfHeaderExtensionObject))
{
throw new CorruptFileException("Object GUID incorrect.");
}
if (file.ReadGuid() != TagLib.Asf.Guid.AsfReserved1)
{
throw new CorruptFileException("Reserved1 GUID expected.");
}
if (file.ReadWord() != 6)
{
throw new CorruptFileException("Invalid reserved WORD. Expected '6'.");
}
uint num = file.ReadDWord();
position += 0x2eL;
while (num > 0)
{
TagLib.Asf.Object item = file.ReadObject(position);
position += (long) item.OriginalSize;
num -= (uint) item.OriginalSize;
this.children.Add(item);
}
}
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:25,代码来源:HeaderExtensionObject.cs
示例14: ContentDescriptionObject
public ContentDescriptionObject(TagLib.Asf.File file, long position) : base(file, position)
{
this.title = string.Empty;
this.author = string.Empty;
this.copyright = string.Empty;
this.description = string.Empty;
this.rating = string.Empty;
if (base.Guid != TagLib.Asf.Guid.AsfContentDescriptionObject)
{
throw new CorruptFileException("Object GUID incorrect.");
}
if (base.OriginalSize < 0x22L)
{
throw new CorruptFileException("Object size too small.");
}
ushort length = file.ReadWord();
ushort num2 = file.ReadWord();
ushort num3 = file.ReadWord();
ushort num4 = file.ReadWord();
ushort num5 = file.ReadWord();
this.title = file.ReadUnicode(length);
this.author = file.ReadUnicode(num2);
this.copyright = file.ReadUnicode(num3);
this.description = file.ReadUnicode(num4);
this.rating = file.ReadUnicode(num5);
}
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:26,代码来源:ContentDescriptionObject.cs
示例15: Get
public static PopularimeterFrame Get(TagLib.Id3v2.Tag tag, string user, bool create)
{
PopularimeterFrame frame;
IEnumerator<Frame> enumerator = tag.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
Frame current = enumerator.Current;
frame = current as PopularimeterFrame;
if ((frame != null) && frame.user.Equals(user))
{
return frame;
}
}
}
finally
{
if (enumerator == null)
{
}
enumerator.Dispose();
}
if (!create)
{
return null;
}
frame = new PopularimeterFrame(user);
tag.AddFrame(frame);
return frame;
}
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:31,代码来源:PopularimeterFrame.cs
示例16: GetMiscTag
public static string[] GetMiscTag(TagLib.File file, string name)
{
//TagLib.Mpeg4.AppleTag apple = (TagLib.Mpeg4.AppleTag)file.GetTag(TagLib.TagTypes.Apple);
//TagLib.Id3v2.Tag id3v2 = (TagLib.Id3v2.Tag)file.GetTag(TagLib.TagTypes.Id3v2);
TagLib.Ogg.XiphComment xiph = (TagLib.Ogg.XiphComment)file.GetTag(TagLib.TagTypes.Xiph);
TagLib.Ape.Tag ape = (TagLib.Ape.Tag)file.GetTag(TagLib.TagTypes.Ape);
//if (apple != null)
//{
// string[] text = apple.GetText(name);
// if (text.Length != 0)
// return text;
//}
//if (id3v2 != null)
// foreach (TagLib.Id3v2.Frame f in id3v2.GetFrames())
// if (f is TagLib.Id3v2.TextInformationFrame && ((TagLib.Id3v2.TextInformationFrame)f).Text != null)
// return ((TagLib.Id3v2.TextInformationFrame)f).Text;
if (xiph != null)
{
string[] l = xiph.GetField(name);
if (l != null && l.Length != 0)
return l;
}
if (ape != null)
{
TagLib.Ape.Item item = ape.GetItem(name);
if (item != null)
return item.ToStringArray();
}
return null;
}
开发者ID:androidhacker,项目名称:DotNetProjs,代码行数:35,代码来源:Tagging.cs
示例17: Get
public static UnsynchronisedLyricsFrame Get(TagLib.Id3v2.Tag tag, string description, string language, bool create)
{
UnsynchronisedLyricsFrame frame;
IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.USLT).GetEnumerator();
try
{
while (enumerator.MoveNext())
{
Frame current = enumerator.Current;
frame = current as UnsynchronisedLyricsFrame;
if (((frame != null) && (frame.Description == description)) && ((language == null) || (language == frame.Language)))
{
return frame;
}
}
}
finally
{
if (enumerator == null)
{
}
enumerator.Dispose();
}
if (!create)
{
return null;
}
frame = new UnsynchronisedLyricsFrame(description, language);
tag.AddFrame(frame);
return frame;
}
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:31,代码来源:UnsynchronisedLyricsFrame.cs
示例18: Get
public static GeneralEncapsulatedObjectFrame Get(TagLib.Id3v2.Tag tag, string description, bool create)
{
GeneralEncapsulatedObjectFrame frame;
IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.GEOB).GetEnumerator();
try
{
while (enumerator.MoveNext())
{
Frame current = enumerator.Current;
frame = current as GeneralEncapsulatedObjectFrame;
if ((frame != null) && (frame.Description == description))
{
return frame;
}
}
}
finally
{
if (enumerator == null)
{
}
enumerator.Dispose();
}
if (!create)
{
return null;
}
frame = new GeneralEncapsulatedObjectFrame {
Description = description
};
tag.AddFrame(frame);
return frame;
}
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:33,代码来源:GeneralEncapsulatedObjectFrame.cs
示例19: Get
public static RelativeVolumeFrame Get(TagLib.Id3v2.Tag tag, string identification, bool create)
{
RelativeVolumeFrame frame;
IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.RVA2).GetEnumerator();
try
{
while (enumerator.MoveNext())
{
Frame current = enumerator.Current;
frame = current as RelativeVolumeFrame;
if ((frame != null) && (frame.Identification == identification))
{
return frame;
}
}
}
finally
{
if (enumerator == null)
{
}
enumerator.Dispose();
}
if (!create)
{
return null;
}
frame = new RelativeVolumeFrame(identification);
tag.AddFrame(frame);
return frame;
}
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:31,代码来源:RelativeVolumeFrame.cs
示例20: Read
protected void Read(TagLib.File file)
{
if (file == null)
return;
try
{
file.Mode = FileAccessMode.Read;
}
catch (TagLibException)
{
return;
}
file.Seek(tagOffset);
header.SetData(file.ReadBlock((int)Id3v2Header.Size));
// if the tag size is 0, then this is an invalid tag (tags must contain
// at least one frame)
if (header.TagSize == 0)
return;
Parse(file.ReadBlock((int)header.TagSize));
}
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:25,代码来源:Id3v2Tag.cs
注:本文中的TagLib类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论