日期:2014-05-18 浏览次数:21102 次
public void Init() { if (_graph != null) { ReleaseGraph(); Marshal.ReleaseComObject(_graph); _graph = null; GC.Collect(); } _graph = new FilterGraph() as IFilterGraph; if (_graph != null) _graph.AddFilter(CreateRenderer() as IBaseFilter, "Video Mixing Renderer 9"); State = MediaState.Close; } public void Open(string filename) { var mediaControl = _graph as IMediaControl; if (mediaControl != null) { mediaControl.RenderFile(filename); State = MediaState.Open; } } private void ReleaseGraph() { IEnumFilters filters = null; _graph.EnumFilters(out filters); IBaseFilter[] filter = new IBaseFilter[1]; while (filters.Next(1, filter, IntPtr.Zero) == 0) { _graph.RemoveFilter(filter[0]); } }