Пример #1
0
        private void SetHighlights()
        {
            //lock (loadDurationLockObj)
            //{
            //    if (duration == nonloadedDuration) duration = GetDuration();
            //}

            //Highlights = collections.GetHighlightCollection(this);

            try
            {
                TextFrame frame;
                ID3File   id3File = new ID3File(FullPath);

                Highlights = TryFindHighlightsFrame(id3File?.ID3v2Tag?.Frames, out frame) ?
                             DeserializeHighlights(frame.Text) : new HighlightCollection();

                Highlights.CollectionChanged += Highlights_CollectionChanged;

                foreach (Highlight highlight in Highlights)
                {
                    highlight.BeginChanged += Highlight_BeginChanged;
                    highlight.EndChanged   += Highlight_EndChanged;
                }
            }
            catch
            {
                Highlights = new HighlightCollection();
            }
        }
Пример #2
0
        public Highlights()
        {
            DurationTicks = 0;
            FirstID       = LastID = -1;

            Collection = new HighlightCollection();
            Collection.CollectionChanged += Collection_CollectionChanged;
        }
        private void Unsubscribe(HighlightCollection collection)
        {
            collection.CollectionChanged -= Highlights_CollectionChanged;

            foreach (Highlight highlight in collection)
            {
                Unsubscribe(highlight);
            }
        }
Пример #4
0
        public Highlights(MediaFile mediaFile)
        {
            //FirstID = mediaFile.FirstID;
            //LastID = mediaFile.CurrentID;
            DurationTicks = mediaFile.Duration.Ticks;
            LastChanged   = DateTime.Now;

            Collection = new HighlightCollection();
            Collection.CollectionChanged += Collection_CollectionChanged;
        }
Пример #5
0
        public MediaFile(string path)
        {
            FullPath = path;
            //CurrentID = Path.GetFileName(FullPath).GetHashCode();
            //FirstID = GetFirstIDFromID3Tag();
            Highlights = null;

            duration = nonloadedDuration;

            SetHighlights();
        }
Пример #6
0
        private string SerializeHighlights(HighlightCollection highlights)
        {
            string dataString           = string.Empty;
            string splitterString       = highlightSplitter.ToString();
            string normalSplitterString = highlightSplitter.ToString() + addChar.ToString();

            foreach (Highlight highlight in highlights)
            {
                dataString += highlight.GetDataString().Replace(splitterString, normalSplitterString) + splitterString;
            }

            return(dataString);
        }