public string this[string AttrName] { get { WMHeaderInfo head = new WMHeaderInfo(HeaderInfo); try { return(head[AttrName].Value.ToString()); } catch (COMException e) { if (e.ErrorCode == WM.ASF_E_NOTFOUND) { return(null); } else { throw (e); } } } }
private void Init(WaveFormat OutputFormat) { m_outputNumber = GetAudioOutputNumber(m_reader); if (m_outputNumber == InvalidOuput) { throw new ArgumentException("An audio stream was not found"); } int[] FormatIndexes = GetPCMOutputNumbers(m_reader, (uint)m_outputNumber); if (FormatIndexes.Length == 0) { throw new ArgumentException("An audio stream was not found"); } if (OutputFormat != null) { m_outputFormatNumber = -1; for (int i = 0; i < FormatIndexes.Length; i++) { WaveFormat fmt = GetOutputFormat(m_reader, (uint)m_outputNumber, (uint)FormatIndexes[i]); if (// (fmt.wFormatTag == OutputFormat.wFormatTag) && (fmt.AverageBytesPerSecond == OutputFormat.AverageBytesPerSecond) && (fmt.BlockAlign == OutputFormat.BlockAlign) && (fmt.Channels == OutputFormat.Channels) && (fmt.SampleRate == OutputFormat.SampleRate) && (fmt.BitsPerSample == OutputFormat.BitsPerSample)) { m_outputFormatNumber = FormatIndexes[i]; m_outputFormat = fmt; break; } } if (m_outputFormatNumber < 0) { throw new ArgumentException("No PCM output found"); } } else { m_outputFormatNumber = FormatIndexes[0]; m_outputFormat = GetOutputFormat(m_reader, (uint)m_outputNumber, (uint)FormatIndexes[0]); } uint OutputCtns = 0; m_reader.GetOutputCount(out OutputCtns); ushort[] StreamNumbers = new ushort[OutputCtns]; WMT_STREAM_SELECTION[] StreamSelections = new WMT_STREAM_SELECTION[OutputCtns]; for (uint i = 0; i < OutputCtns; i++) { m_reader.GetStreamNumberForOutput(i, out StreamNumbers[i]); if (i == m_outputNumber) { StreamSelections[i] = WMT_STREAM_SELECTION.WMT_ON; m_outputStream = StreamNumbers[i]; m_reader.SetReadStreamSamples(m_outputStream, false); } else { StreamSelections[i] = WMT_STREAM_SELECTION.WMT_OFF; } } m_reader.SetStreamsSelected((ushort)OutputCtns, StreamNumbers, StreamSelections); IWMOutputMediaProps Props = null; m_reader.GetOutputFormat((uint)m_outputNumber, (uint)m_outputFormatNumber, out Props); m_reader.SetOutputProps((uint)m_outputNumber, Props); uint Size = 0; Props.GetMediaType(IntPtr.Zero, ref Size); IntPtr buffer = Marshal.AllocCoTaskMem((int)Size); try { WM_MEDIA_TYPE mt; Props.GetMediaType(buffer, ref Size); mt = (WM_MEDIA_TYPE)Marshal.PtrToStructure(buffer, typeof(WM_MEDIA_TYPE)); m_sampleSize = mt.lSampleSize; } finally { Marshal.FreeCoTaskMem(buffer); Props = null; } m_seekable = false; m_length = -1; WMHeaderInfo head = new WMHeaderInfo(HeaderInfo); try { m_seekable = (bool)head[WM.g_wszWMSeekable]; // Yuval Naveh ulong nanoDuration = (ulong)head[WM.g_wszWMDuration]; m_duration = new TimeSpan((long)nanoDuration); m_length = SampleTime2BytePosition(nanoDuration); } catch (COMException e) { if (e.ErrorCode != WM.ASF_E_NOTFOUND) { throw (e); } } }
public string this[string AttrName] { get { WMHeaderInfo head = new WMHeaderInfo(HeaderInfo); try { return head[AttrName].Value.ToString(); } catch (COMException e) { if (e.ErrorCode == WM.ASF_E_NOTFOUND) { return null; } else { throw (e); } } } }