/// <summary> /// Setup the IMediaSeeking interface /// </summary> protected void SetMediaSeekingInterface(IMediaSeeking mediaSeeking) { m_mediaSeeking = mediaSeeking; if (mediaSeeking == null) { CurrentPositionFormat = MediaPositionFormat.None; Duration = 0; return; } /* Get our prefered DirectShow TimeFormat */ Guid preferedFormat = ConvertPositionFormat(PreferedPositionFormat); /* Attempt to set the time format */ mediaSeeking.SetTimeFormat(preferedFormat); Guid currentFormat; /* Gets the current time format * we may not have been successful * setting our prefered format */ mediaSeeking.GetTimeFormat(out currentFormat); /* Set our property up with the right format */ CurrentPositionFormat = ConvertPositionFormat(currentFormat); SetDuration(); }
/// <summary> /// Check Format related functions /// </summary> void TestFormats() { int hr; Guid pFormat; // Query to see what the preferred time format is hr = m_ims.QueryPreferredFormat(out pFormat); Marshal.ThrowExceptionForHR(hr); // Is the preferred format supported? Certainly hope so. hr = m_ims.IsFormatSupported(pFormat); Marshal.ThrowExceptionForHR(hr); // Might return and S_ code Debug.Assert(hr == 0); // Read the current time format hr = m_ims.GetTimeFormat(out pFormat); Marshal.ThrowExceptionForHR(hr); // See if the current format is the one we are using. // Better be. hr = m_ims.IsUsingTimeFormat(pFormat); Marshal.ThrowExceptionForHR(hr); // Try setting the format to the current value (the // only one we are sure is supported). hr = m_ims.SetTimeFormat(pFormat); Marshal.ThrowExceptionForHR(hr); }