コード例 #1
0
        public void CreateChapters(string filename, double parsedlength)
        {
            try
            {
                _data.Clear();
                _target.Items.Clear();

                var extension = Path.GetExtension(filename).ToLower();

                if (extension == ".mp3")
                {
                    TagLib.File f = TagLib.File.Create(filename);
                    if (CreateChapters(f.Tag.Lyrics) < 1)
                    {
                        CreateChapters(parsedlength);
                    }
                }
                else if ((extension != ".mp4") && (extension != ".m4a") && (extension != ".m4b"))
                {
                    CreateChapters(parsedlength);
                    return;
                }
                else
                {
                    using (var stream = File.OpenRead(filename))
                    {
                        var extractor = new ChapterExtractor(new StreamWrapper(stream));
                        extractor.Run();
                        foreach (var c in extractor.Chapters)
                        {
                            _data.Add(c.Time.TotalSeconds, c.Name);
                        }
                    }
                }
                DrawToMenu();
            }
            catch (Exception)
            {
                _data.Clear();
                CreateChapters(parsedlength);
            }
        }
コード例 #2
0
        private static List <Chapter> CreateChaptersMpeg4(string filename)
        {
            List <Chapter> ret = new List <Chapter>();

            using (var stream = File.OpenRead(filename))
            {
                var extractor = new ChapterExtractor(new StreamWrapper(stream));
                extractor.Run();
                if (extractor.Chapters != null && extractor.Chapters.Length > 0)
                {
                    foreach (var chapter in extractor.Chapters)
                    {
                        ret.Add(new Chapter
                        {
                            Title    = chapter.Name,
                            Position = chapter.Time.TotalSeconds
                        });
                    }
                }
            }
            return(ret);
        }
コード例 #3
0
        public void CreateChapters(string filename, double parsedlength)
        {
            try
            {
                _data.Clear();
                _target.Items.Clear();

                var extension = Path.GetExtension(filename).ToLower();

                if ((extension != ".mp4") && (extension != ".m4a") && (extension != ".m4b"))
                {
                    CreateChapters(parsedlength);
                    ChaptersEnabled = _data.Count > 0;
                    return;
                }

                using (var stream = File.OpenRead(filename))
                {
                    var extractor = new ChapterExtractor(new StreamWrapper(stream));
                    extractor.Run();
                    if (extractor.Chapters != null)
                    {
                        foreach (var c in extractor.Chapters)
                        {
                            _data.Add(c.Time.TotalSeconds, c.Name);
                        }
                    }
                }
                ChaptersEnabled = _data.Count > 0;
            }
            catch (Exception)
            {
                _data.Clear();
                CreateChapters(parsedlength);
                DrawToMenu();
            }
        }