/// <summary> /// Sets a property value. /// </summary> /// <param name="propertyStore">The property store to set the property in.</param> /// <param name="property">The property to set.</param> /// <param name="value">The value to set the property to.</param> private static void SetPropertyValue(IPropertyStore propertyStore, PropertyKey property, string value) { var variant = new PropertyVariant(value); propertyStore.SetValue(ref property, ref variant); variant.Dispose(); }
private long GetLength(MFSourceReader reader) { lock (_lockObj) { try { if (reader == null) { return(0); } PropertyVariant value = reader.GetPresentationAttribute(MFInterops.MF_SOURCE_READER_MEDIASOURCE, MediaFoundationAttributes.MF_PD_DURATION); var length = ((value.HValue) * _waveFormat.BytesPerSecond) / 10000000L; value.Dispose(); return(length); } catch (Exception) { //if (e.Result == (int)HResult.MF_E_ATTRIBUTENOTFOUND) // return 0; //throw; return(0); } } }