Example #1
0
        private void Reposition(long desiredPosition)
        {
            long nsPosition = (10000000L * repositionTo) / waveFormat.AverageBytesPerSecond;
            var  pv         = PropVariant.FromLong(nsPosition);

            // should pass in a variant of type VT_I8 which is a long containing time in 100nanosecond units
            pReader.SetCurrentPosition(Guid.Empty, ref pv);
            decoderOutputCount  = 0;
            decoderOutputOffset = 0;
            position            = desiredPosition;
            repositionTo        = -1;// clear the flag
        }
        /// <summary>
        /// Seeks to a new position in the media source.
        /// </summary>
        /// <param name="sourceReader">A valid IMFSourceReader instance.</param></param></param>
        /// <param name="position">The position from which playback will be started.</param>
        /// <returns>If this function succeeds, it returns the S_OK member. Otherwise, it returns another HResult's member that describe the error.</returns>
        public static HResult SetCurrentPosition(this IMFSourceReader sourceReader, TimeSpan position)
        {
            if (sourceReader == null)
            {
                throw new ArgumentNullException("sourceReader");
            }

            using (PropVariant value = new PropVariant(position.Ticks))
            {
                return(sourceReader.SetCurrentPosition(Guid.Empty, value));
            }
        }
Example #3
0
        private void Reposition(long desiredPosition)
        {
            long nsPosition = (10000000L * repositionTo) / waveFormat.AverageBytesPerSecond;
            var  pv         = PropVariant.FromLong(nsPosition);
            var  ptr        = Marshal.AllocHGlobal(Marshal.SizeOf(pv));

            Marshal.StructureToPtr(pv, ptr, false);

            // should pass in a variant of type VT_I8 which is a long containing time in 100nanosecond units
            pReader.SetCurrentPosition(Guid.Empty, ptr);
            Marshal.FreeHGlobal(ptr);
            decoderOutputCount  = 0;
            decoderOutputOffset = 0;
            position            = desiredPosition;
            repositionTo        = -1;// clear the flag
        }