DirectShow.Net包含示例項目DxPlay,播放不帶音頻的視頻。我需要修改這個項目才能播放音頻。我已閱讀我需要添加音頻過濾器並連接到引腳,但我沒有找到一種方法來做到這一點。DirectShow.Net播放帶有音頻的視頻
下面是從設置過濾器了樣本代碼:
// Add the filters necessary to render the file. This function will
// work with a number of different file types.
IBaseFilter sourceFilter = null;
hr = m_FilterGraph.AddSourceFilter(FileName, FileName, out sourceFilter);
DsError.ThrowExceptionForHR(hr);
// Get the SampleGrabber interface
m_sampGrabber = (ISampleGrabber)new SampleGrabber();
IBaseFilter baseGrabFlt = (IBaseFilter)m_sampGrabber;
// Configure the Sample Grabber
ConfigureSampleGrabber(m_sampGrabber);
// Add it to the filter
hr = m_FilterGraph.AddFilter(baseGrabFlt, "Ds.NET Grabber");
DsError.ThrowExceptionForHR(hr);
// Connect the pieces together, use the default renderer
hr = icgb2.RenderStream(null, null, sourceFilter, baseGrabFlt, null);
DsError.ThrowExceptionForHR(hr);
可否請你提示我,我怎樣才能使它播放音頻?
另一個額外的'RenderStream',MEDIATYPE_Audio'作爲第二個參數('sourceFilter' /'null'爲第三個,其餘爲'null's)? –
@RomanR。,添加了icgb2.RenderStream(null,MediaType.Audio,sourceFilter,null,null) - 它工作。謝謝! – SiberianGuy