Beispiel #1
0
        public static AudioCDInformation ReadAudioCDInformation(char driveLetter)
        {
            CdromFileInfo[] files  = ReadAllTracks(driveLetter);
            CdtextData      cdtext = ReadCdtextData(driveLetter);

            CdromFileInfo firstFile = files[0];
            CdromFileInfo lastFile  = files[files.Length - 1];

            AudioCDInformation audioCd = new AudioCDInformation();

            audioCd.CDCatalogNumber     = cdtext.DiskId;
            audioCd.CdaDiskSerialNumber = files[0].DiskSerialNumber;
            audioCd.CddbDiskId          = GetCddbDiskId(files);
            audioCd.TrackCount          = files.Length;
            audioCd.TotalDuration       = (lastFile.StartFrom + lastFile.Duration).TotalSeconds;
            audioCd.Metadata            = CreateMetadata(cdtext, 0);

            audioCd.Tracks = new AudioTrackInformation[files.Length];
            for (int i = 0; i < files.Length; i++)
            {
                AudioTrackInformation track = new AudioTrackInformation();
                track.TrackNumber = i + 1;
                track.Filename    = Path.GetFileName(files[i].Path);
                track.Metadata    = CreateMetadata(cdtext, i + 1);
                track.StartFrom   = files[i].StartFrom.TotalSeconds;
                track.Duration    = files[i].Duration.TotalSeconds;
                track.StartSector = files[i].StartSector;
                track.SectorCount = files[i].SectorCount;
                track.Metadata    = CreateMetadata(cdtext, i + 1);

                audioCd.Tracks[i] = track;
            }

            return(audioCd);
        }
Beispiel #2
0
        public static AudioCDInformation ReadAudioCDInformation(char driveLetter)
        {
            CdromFileInfo[] files = ReadAllTracks(driveLetter);
            CdtextData cdtext = ReadCdtextData(driveLetter);

            CdromFileInfo firstFile = files[0];
            CdromFileInfo lastFile = files[files.Length - 1];

            AudioCDInformation audioCd = new AudioCDInformation();
            audioCd.CDCatalogNumber = cdtext.DiskId;
            audioCd.CdaDiskSerialNumber = files[0].DiskSerialNumber;
            audioCd.CddbDiskId = GetCddbDiskId(files);
            audioCd.TrackCount = files.Length;
            audioCd.TotalDuration = (lastFile.StartFrom + lastFile.Duration).TotalSeconds;
            audioCd.Metadata = CreateMetadata(cdtext, 0);

            audioCd.Tracks = new AudioTrackInformation[files.Length];
            for (int i = 0; i < files.Length; i++)
            {
                AudioTrackInformation track = new AudioTrackInformation();
                track.TrackNumber = i + 1;
                track.Filename = Path.GetFileName(files[i].Path);
                track.Metadata = CreateMetadata(cdtext, i + 1);
                track.StartFrom = files[i].StartFrom.TotalSeconds;
                track.Duration = files[i].Duration.TotalSeconds;
                track.StartSector = files[i].StartSector;
                track.SectorCount = files[i].SectorCount;
                track.Metadata = CreateMetadata(cdtext, i + 1);

                audioCd.Tracks[i] = track;
            }

            return audioCd;
        }
Beispiel #3
0
 private static void SaveAudioCDInformation(string path, AudioCDInformation cdInformation)
 {
     XmlSerializer ser = new XmlSerializer(typeof(AudioCDInformation));
     XmlWriterSettings writerSettings = new XmlWriterSettings();
     writerSettings.Indent = true;
     using (XmlWriter writer = XmlWriter.Create(path, writerSettings))
     {
         ser.Serialize(writer, cdInformation);
     }
 }