Esempio n. 1
0
        /// <summary>
        /// Gets the current playback position.
        /// </summary>
        /// <param name="mediaPlayer">A valid IMFPMediaPlayer instance.</param>
        /// <param name="durationValue">Receives the playback position.</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 GetPosition(this IMFPMediaPlayer mediaPlayer, out TimeSpan positionValue)
        {
            if (mediaPlayer == null)
            {
                throw new ArgumentNullException("mediaPlayer");
            }

            using (PropVariant result = new PropVariant())
            {
                HResult hr = mediaPlayer.GetPosition(Guid.Empty, result);
                positionValue = hr.Succeeded() ? TimeSpan.FromTicks((long)result.GetULong()) : default(TimeSpan);

                return(hr);
            }
        }