示例#1
0
        public static void startSecond()
        {
            initDSArrays();



            filter1 = (DirectShowLib.IBaseFilter) new DirectShowLib.VideoMixingRenderer9();
            DirectShowLib.IVMRFilterConfig9 filterConfig = (DirectShowLib.IVMRFilterConfig9)filter1;
            filterConfig.SetRenderingMode(VMR9Mode.Renderless);
            filterConfig.SetNumberOfStreams(2);


            DirectShowLib.IVMRSurfaceAllocatorNotify9 vmrSurfAllocNotify = (DirectShowLib.IVMRSurfaceAllocatorNotify9)filter1;

            try
            {
                int hr = vmrSurfAllocNotify.AdviseSurfaceAllocator(userId1, allocator);
                DsError.ThrowExceptionForHR(hr);

                hr = allocator.AdviseNotify(vmrSurfAllocNotify);
                DsError.ThrowExceptionForHR(hr);
            }
            catch { }



            graph1 = (DirectShowLib.IGraphBuilder) new DirectShowLib.FilterGraph();
            graph1.AddFilter(filter1, "Video Mixing Renderer 9");

            graph1.RenderFile(@"C:\Download\workmates.wmv", null);
            mediaControl1 = (DirectShowLib.IMediaControl)graph1;
            mediaControl1.Run();
        }
示例#2
0
        /// <summary>
        /// Load a video to setup DirectShow. This also initally creates an instance of the DirectX3D Device
        /// </summary>
        public static void StartGraph()
        {
            int hr = 0;

            //CloseGraph();

            string path = @"opensebj.wmv";

            try
            {
                graph  = (DirectShowLib.IGraphBuilder) new DirectShowLib.FilterGraph();
                filter = (DirectShowLib.IBaseFilter) new DirectShowLib.VideoMixingRenderer9();

                DirectShowLib.IVMRFilterConfig9 filterConfig = (DirectShowLib.IVMRFilterConfig9)filter;

                hr = filterConfig.SetRenderingMode(VMR9Mode.Renderless);
                DsError.ThrowExceptionForHR(hr);

                hr = filterConfig.SetNumberOfStreams(2);
                DsError.ThrowExceptionForHR(hr);

                SetAllocatorPresenter();

                hr = graph.AddFilter(filter, "Video Mixing Renderer 9");
                DsError.ThrowExceptionForHR(hr);

                hr = graph.RenderFile(path, null);
                DsError.ThrowExceptionForHR(hr);

                mediaControl = (DirectShowLib.IMediaControl)graph;
            }
            catch
            {
            }
        }
示例#3
0
        public static Boolean TryMediaOpen(MediaTypes mediaType, String path)
        {
            Boolean ret = false;

            switch (mediaType)
            {
            case MediaTypes.Audio:
            {
                DirectShowLib.IGraphBuilder gb = (DirectShowLib.IGraphBuilder) new DirectShowLib.FilterGraph();
                //Int32 hr = gb.RenderFile(path, null);
                if (gb.RenderFile(path, null) == 0)
                {
                    ret = true;
                }
                Marshal.ReleaseComObject(gb);
                gb = null;
                break;
            }

            case MediaTypes.Video:
            {
                DirectShowLib.IGraphBuilder gb = (DirectShowLib.IGraphBuilder) new DirectShowLib.FilterGraph();
                Int32 hr = gb.RenderFile(path, null);
                if (hr == 0)
                {
                    DirectShowLib.IVideoWindow videoWindow = (DirectShowLib.IVideoWindow)gb;
                    OABool lVisible;
                    if (videoWindow.get_Visible(out lVisible) == 0)
                    {
                        ret = true;
                    }
                    videoWindow = null;
                }
                Marshal.ReleaseComObject(gb);
                gb = null;
                break;
            }

            case MediaTypes.Karaoke:
            {
                ret = true;
                try
                {
                    Sequence sequence = new Sequence(path);
                    sequence.Dispose();
                }
                catch (Exception)
                {
                    ret = false;
                }
                break;
            }

            default:
                break;
            }
            return(ret);
        }
示例#4
0
        public AudioVideoBase(String path, Boolean isDemo)
            : base(isDemo, path)
        {
            m_GraphBuilder = (DirectShowLib.IGraphBuilder) new FilterGraph();
            m_hr           = m_GraphBuilder.RenderFile(path, null);
            DsError.ThrowExceptionForHR(m_hr);

            m_MediaControl  = (DirectShowLib.IMediaControl)m_GraphBuilder;
            m_MediaPosition = (DirectShowLib.IMediaPosition)m_GraphBuilder;
            m_BasicAudio    = (DirectShowLib.IBasicAudio)m_GraphBuilder;
        }