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