예제 #1
0
파일: ID3V23.cs 프로젝트: Epibatidin/FLUX
        private void CreateV1Frame(Stream stream)
        {
            // ID1 header am ende ...
            stream.Seek(-125, SeekOrigin.End);
            // 30 zeichen title     => TIT2
            // 30 zeichen artist    => TCOM
            // 30 zeichen album     => TALB
            // 4 zeichen jahr       => TYER
            // 30 zeichen commentar - kann auch den track enthalten (TRCK) - der letzte byte
            // 1 byte Genre
            // == 125

            foreach (var item in new[] { "TIT2", "TCOM", "TALB" })
            {
                AddNonEmptyFrame(item, stream.Read(30));
            }
            AddNonEmptyFrame("TYER", stream.Read(4));

            // comment - egal
            stream.Seek(28, SeekOrigin.Current);
            var track = stream.Read(2);
            if (track[0] == 0 && track[1] != 0)
            {
                // dann ist track[1] eine zahl;
                if (track[1] < 48)
                {
                    Frame f = new Frame("TRCK");
                    f.FrameData = ((int)track[1]).ToString();
                    Frames.Add(f);
                }
            }
        }
예제 #2
0
파일: ID3V23.cs 프로젝트: Epibatidin/FLUX
        private Stream FrameObjectToByteArray(Frame F)
        {
            var byteValues = ByteHelper.StringToByte(F.FrameData);
            int DataSize = byteValues.Length + 1;

            MemoryStream temp = new MemoryStream();
            //  Frame ID       $xx xx xx xx (four characters)
            temp.Write(ByteHelper.StringToByte(F.FrameID));
            //  Size           $xx xx xx xx

            var blub = ByteHelper.GetBytesFromInt32(DataSize);
            temp.Write(blub);
            //  Flags          $xx xx
            // keine flags
            temp.Write(new byte[] {0, 0} , 0 , 2);
            // und das wichtigste die DATEN
            // als erstes das (die) extra encoder byte(s)
            temp.Write(new byte[] { 0 });
            // dann die daten
            temp.Write(byteValues);
            temp.Seek(0, SeekOrigin.Begin);

            return temp;
        }
예제 #3
0
파일: ID3V23.cs 프로젝트: Epibatidin/FLUX
        private void AddNonEmptyFrame(string FrameID, byte[] Value)
        {
            var framedata = ByteHelper.BytesToString(Value);
            if (String.IsNullOrEmpty(framedata))
                return;

            Frame f = new Frame(FrameID);
            f.FrameData = framedata;
            Frames.Add(f);
        }
예제 #4
0
파일: ID3V23.cs 프로젝트: Epibatidin/FLUX
        private Frame CreateV3Frame(Stream stream)
        {
            // Frame ID   $xx xx xx xx (four characters)
            var frameIDBytes = stream.Read(4);

            if (frameIDBytes[0] == 0)
                return null;

            string FrameID = ByteHelper.BytesToString(frameIDBytes);

            Frame F = new Frame(FrameID);
            // Size                               $xx xx xx xx
            int DataSize = ByteHelper.GetInt32FromBytes(stream.Read(4));

            // Flags          $xx xx
            F.SetFlags(stream.Read(2));

            if (FrameID[0] == 'T')
                F.FrameData = readTextFrame(stream, DataSize);
            else if (FrameID == "APIC")
            {
                //<Header for 'Attached picture', ID: "APIC">
                //Text encoding   $xx
                //MIME type       <text string> $00
                //Picture type    $xx
                //Description     <text string according to encoding> $00 (00)
                //Picture data    <binary data>

                F.FrameData = "Images - currently not supported";
                stream.Seek(DataSize, SeekOrigin.Current);
            }
            else
                F.FrameData = ByteHelper.BytesToString(stream.Read(DataSize));
            return F;
        }