Esempio n. 1
0
        /// <summary>
        /// Get the closest sliver to this time.
        /// </summary>
        /// <remarks>
        /// Will be returned as a Slice with duration 1.
        /// </remarks>
        public Slice <Frame, TValue> GetClosestSliver(Time <TTime> sourceTime)
        {
            sourceTime = MapTime(sourceTime);

            for (int i = _times.Count - 1; i >= 0; i--)
            {
                if (_times[i] < sourceTime)
                {
                    return(_innerStream.GetNextSliceAt(new Interval <Frame>(i, 1)));
                }
            }

            // if didn't find closest by time going backwards, just return the last available one
            // (since this means you need to wrap around the loop)
            if (_times.Count > 0)
            {
                return(_innerStream.GetNextSliceAt(new Interval <Frame>(_times.Count - 1, 1)));
            }
            else
            {
                return(Slice <Frame, TValue> .Empty);
            }
        }