예제 #1
0
        /// <summary>
        /// Reads metadata from files with an ID3 tag, using an <see cref="ID3info"/> object.
        /// </summary>
        /// <param name="filepath">The full path of the file from which to read.</param>
        /// <returns>A <see cref="RawTrack"/> containing the parsed metadata, if parsing succeeded. If parsing fails an exception is thrown.</returns>
        public override RawTrack ParseTrack(string filepath)
        {
            ID3info id3 = new ID3info(filepath);
            if (!id3.ID3v1.TagFound && !id3.ID3v2.TagFound)
                throw new Exception("No tags found.");

            return new RawTrack(filepath, id3.Title, id3.Album, id3.TrackNumber, id3.Artist);
        }
예제 #2
0
        public static void Write(ID3info item, Stream output)
        {
            int length = byteCount(item.file.FullName)
                       + byteCount(item.artist)
                       + byteCount(item.album)
                       + byteCount(item.title)
                       + byteCount(item.trackstring)
                       + byteCount(item.tracknumber);

            write(output, length);
            write(output, item.file.FullName);
            write(output, item.artist);
            write(output, item.album);
            write(output, item.title);
            write(output, item.trackstring);
            write(output, item.tracknumber);
        }
예제 #3
0
        public static ID3info Read(Stream input)
        {
            int length = readint(input);

            ID3info item = new ID3info();

            item.file = new FileInfo(readstring(input));
            item.artist = readstring(input);
            item.album = readstring(input);
            item.title = readstring(input);
            item.trackstring = readstring(input);
            item.tracknumber = readint(input);

            return item;
        }