private long GetLength(MFSourceReader reader) { lock (_lockObj) { try { if (reader == null) { return(0); } using ( PropertyVariant value = reader.GetPresentationAttribute(NativeMethods.MF_SOURCE_READER_MEDIASOURCE, MediaFoundationAttributes.MF_PD_DURATION)) { //bug: still, depending on the decoder, this returns imprecise values. return(NanoSecond100UnitsToBytes(value.HValue)); } } catch (Exception) { return(0); } } }
private long GetLength(MFSourceReader reader) { lock (_lockObj) { try { if (reader == null) { return(0); } using ( PropertyVariant value = reader.GetPresentationAttribute(NativeMethods.MF_SOURCE_READER_MEDIASOURCE, MediaFoundationAttributes.MF_PD_DURATION)) { //bug: still, depending on the decoder, this returns imprecise values. return(((value.HValue) * _waveFormat.BytesPerSecond) / 10000000L); } } catch (Exception) { //if (e.Result == (int)HResult.MF_E_ATTRIBUTENOTFOUND) // return 0; //throw; return(0); } } }
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); } } }
private long GetLength(MFSourceReader reader) { lock (_lockObj) { try { if (reader == null) return 0; using ( PropertyVariant value = reader.GetPresentationAttribute(NativeMethods.MF_SOURCE_READER_MEDIASOURCE, MediaFoundationAttributes.MF_PD_DURATION)) { //bug: still, depending on the decoder, this returns imprecise values. return NanoSecond100UnitsToBytes(value.HValue); } } catch (Exception) { return 0; } } }
private long GetLength(MFSourceReader reader) { lock (_lockObj) { try { if (reader == null) return 0; using ( PropertyVariant value = reader.GetPresentationAttribute(NativeMethods.MF_SOURCE_READER_MEDIASOURCE, MediaFoundationAttributes.MF_PD_DURATION)) { //bug: still, depending on the decoder, this returns imprecise values. return ((value.HValue) * _waveFormat.BytesPerSecond) / 10000000L; } } catch (Exception) { //if (e.Result == (int)HResult.MF_E_ATTRIBUTENOTFOUND) // return 0; //throw; return 0; } } }
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; } } }