コード例 #1
0
        public ChapterInfo(ChapterInfo chapter)
        {
            StartTime = chapter.StartTime; EndTime = chapter.EndTime; StartOffset = chapter.StartOffset; EndOffset = chapter.EndOffset; Title = chapter.Title; Subtitle = chapter.Subtitle; Url = chapter.Url; UniqueID = chapter.UniqueID;

            if (chapter.Url != null)
            {
                Url = new UrlInfo(chapter.Url);
            }
            if (chapter.Picture != null)
            {
                Picture = new PictureInfo(chapter.Picture);
            }
        }
コード例 #2
0
ファイル: TagData.cs プロジェクト: jda808/atldotnet
        /// <summary>
        /// Cleanup field values that need to be reformatted : track and disc numbers, chapter data
        /// </summary>
        public void Cleanup()
        {
            if (TrackNumber != null && TrackNumber.Contains("/"))
            {
                TrackNumberTotal = TrackNumber;
                string[] parts = TrackNumber.Split('/');
                TrackNumber = parts[0];
                TrackTotal  = parts[1];
            }
            else if (Utils.IsNumeric(TrackNumber))
            {
                TrackNumberTotal = TrackNumber;
                if (Utils.IsNumeric(TrackTotal))
                {
                    TrackNumberTotal += "/" + TrackTotal;
                }
            }

            if (DiscNumber != null && DiscNumber.Contains("/"))
            {
                DiscNumberTotal = DiscNumber;
                string[] parts = DiscNumber.Split('/');
                DiscNumber = parts[0];
                DiscTotal  = parts[1];
            }
            else if (Utils.IsNumeric(DiscNumber))
            {
                DiscNumberTotal = DiscNumber;
                if (Utils.IsNumeric(DiscTotal))
                {
                    DiscNumberTotal += "/" + DiscTotal;
                }
            }

            if (Chapters != null && Chapters.Count > 0)
            {
                // Sort by start offset or time
                if (Chapters[0].UseOffset)
                {
                    Chapters = Chapters.OrderBy(chapter => chapter.StartOffset).ToList();
                }
                else
                {
                    Chapters = Chapters.OrderBy(chapter => chapter.StartTime).ToList();
                }

                // Auto-fill end offsets or times except for final chapter
                ChapterInfo previousChapter = null;
                foreach (ChapterInfo chapter in Chapters)
                {
                    if (previousChapter != null)
                    {
                        if (chapter.UseOffset && (0 == previousChapter.EndOffset || previousChapter.EndOffset != chapter.StartOffset))
                        {
                            previousChapter.EndOffset = chapter.StartOffset;
                        }
                        else if (0 == previousChapter.EndTime || previousChapter.EndTime != chapter.StartTime)
                        {
                            previousChapter.EndTime = chapter.StartTime;
                        }
                    }
                    previousChapter = chapter;
                }
                // Calculate duration of final chapter with duration of audio
                if (previousChapter != null && 0 == previousChapter.EndTime)
                {
                    previousChapter.EndTime = (uint)Math.Round(DurationMs);
                }
            }
        }