Logo Search packages:      
Sourcecode: taglib-sharp version File versions

TagLib::Id3v2::PlayCountFrame Class Reference

Inheritance diagram for TagLib::Id3v2::PlayCountFrame:

List of all members.


Detailed Description

This class extends Frame, implementing support for ID3v2 Play Count (PCNT) Frames.

Getting and incrementing the play count of a file.

          using TagLib;
          using TagLib.Id3v2;

          public static class TrackUtil
          {
            public static int GetPlayCount (string filename)
            {
                  File file = File.Create (filename, ReadStyle.None);
                  Id3v2.Tag tag = file.GetTag (TagTypes.Id3v2, false) as Id3v2.Tag;
                  if (tag == null)
                        return 0;

                  PlayCountFrame frame = PlayCountFrame.Get (tag, false);
                  if (frame == null)
                        return 0;

                  return frame.PlayCount;
            }

            public static void IncrementPlayCount (string filename)
            {
                  File file = File.Create (filename, ReadStyle.None);
                  Id3v2.Tag tag = file.GetTag (TagTypes.Id3v2, true) as Id3v2.Tag;
                  if (tag == null)
                        return;

                  PlayCountFrame.Get (tag, true).PlayCount ++;
                  file.Save ();
            }
          }
          #using <System.dll>
          #using <taglib-sharp.dll>

          using System;
          using TagLib;
          using TagLib::Id3v2;

          public ref class TrackUtil abstract sealed
          {
          public:
            static int GetPlayCount (String^ filename)
            {
                  File^ file = File.Create (filename, ReadStyle.None);
                  Id3v2::Tag^ tag = dynamic_cast<Id3v2::Tag^> (file.GetTag (TagTypes::Id3v2, false));
                  if (tag == null)
                        return 0;

                  PlayCountFrame^ frame = PlayCountFrame::Get (tag, false);
                  if (frame == null)
                        return 0;

                  return frame->PlayCount;
            }

            static void IncrementPlayCount (String^ filename)
            {
                  File^ file = File::Create (filename, ReadStyle::None);
                  Id3v2.Tag^ tag = dynamic_cast<Id3v2::Tag^> (file.GetTag (TagTypes::Id3v2, true));
                  if (tag == null)
                        return;

                  PlayCountFrame::Get (tag, true)->PlayCount ++;
                  file->Save ();
            }
          }
          Imports TagLib
          Imports TagLib.Id3v2

          Public Shared Class TrackUtil
            Public Shared Sub GetPlayCount (filename As String) As Integer
                  Dim file As File = File.Create (filename, ReadStyle.None)
                  Dim tag As Id3v2.Tag = file.GetTag (TagTypes.Id3v2, False)
                  If tag Is Nothing Then Return 0

                  Dim frame As PlayCountFrame = PlayCountFrame.Get (tag, False)
                  If frame Is Nothing Then Return 0

                  Return frame.PlayCount
            End Sub

            Public Shared Sub IncrementPlayCount (filename As String)
                  Dim file As File = File.Create (filename, ReadStyle.None)
                  Dim tag As Id3v2.Tag = file.GetTag (TagTypes.Id3v2, True)
                  If tag Is Nothing Then Exit Sub

                  PlayCountFrame.Get (tag, True).PlayCount += 1
                  file.Save ()
            End Sub
          End Class
          import TagLib
          import TagLib.Id3v2

          public static class TrackUtil:
            static def GetPlayCount (filename as string) as int:
                  file As File = File.Create (filename, ReadStyle.None)
                  tag as Id3v2.Tag = file.GetTag (TagTypes.Id3v2, false)
                  if tag == null:
                        return 0

                  frame as PlayCountFrame = PlayCountFrame.Get (tag, false)
                  if frame == null:
                        return 0

                  return frame.PlayCount

            static def IncrementPlayCount (filename as string):
                  file as File = File.Create (filename, ReadStyle.None)
                  tag as Id3v2.Tag = file.GetTag (TagTypes.Id3v2, True)
                  if tag == null:
                        return

                  PlayCountFrame.Get (tag, true).PlayCount ++
                  file.Save ()

Definition at line 161 of file PlayCountFrame.cs.


Public Member Functions

 PlayCountFrame (ByteVector data, byte version)
 Constructs and initializes a new instance of PlayCountFrame by reading its raw data in a specified ID3v2 version.
 PlayCountFrame ()
 Constructs and initializes a new instance of PlayCountFrame with a count of zero.
virtual ByteVector Render (byte version)

Static Public Member Functions

static PlayCountFrame Get (Tag tag, bool create)
 Gets a play count frame from a specified tag, optionally creating it if it does not exist.
static ByteVector TextDelimiter (StringType type)

Protected Member Functions

ByteVector FieldData (ByteVector frameData, int offset, byte version)
override void ParseFields (ByteVector data, byte version)
 Populates the values in the current instance by parsing its field data in a specified version.
internal PlayCountFrame (ByteVector data, int offset, FrameHeader header, byte version)
 Constructs and initializes a new instance of PlayCountFrame by reading its raw data in a specified ID3v2 version.
override ByteVector RenderFields (byte version)
 Renders the values in the current instance into field data for a specified version.
void SetData (ByteVector data, int offset, byte version, bool readHeader)

Static Protected Member Functions

static StringType CorrectEncoding (StringType type, byte version)

Properties

short EncryptionId [get, set]
FrameFlags Flags [get, set]
ReadOnlyByteVector FrameId [get]
short GroupId [get, set]
ulong PlayCount [get, set]
 Gets and sets the play count of the current instance.
uint Size [get]

Private Attributes

ulong play_count = 0
 Contains the total number of times the file has been played.

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index