示例#1
0
        public PlayerCore(string file)
        {
            graphBuilder = (new FilterGraph()) as IFilterGraph2;
            if (graphBuilder == null) return;
            mediaControl = graphBuilder as IMediaControl;
            mediaSeeking = graphBuilder as IMediaSeeking;
            audioControl = graphBuilder as IBasicAudio;
            if (mediaControl == null || mediaSeeking == null || audioControl == null) return;
            //int hr = mediaControl.RenderFile(file);
            FileInfo info = new FileInfo(file);
            ISupport support = Supports.Instance[info.Extension];
            int hr = -1;
            if (support != null)
                hr = support.RenderGraph(graphBuilder, file);
            else
                hr = mediaControl.RenderFile(file);

            fileName = file;
            if (hr != 0) errorStack.Push(hr);
            if (hr != 0) return;
            mediaSeeking.SetTimeFormat(TimeFormat.MediaTime);
            isValidate = true;
            window = graphBuilder as IVideoWindow;
            if (window != null)
            {
                int width = 0;
                int height = 0;
                window.get_Width(out width);
                window.get_Height(out height);
                nativeSize = new Size(width, height);
            }
        }
示例#2
0
        ////////////////
        /// Get/Put Width
        private void TestWidth()
        {
            int hr;
            int Width1, Width2;

            // Read the current value
            hr = m_ivw.get_Width(out Width1);
            Marshal.ThrowExceptionForHR(hr);

            // Change it
            hr = m_ivw.put_Width(Width1 + 1);
            Marshal.ThrowExceptionForHR(hr);

            // Re-read
            hr = m_ivw.get_Width(out Width2);
            Marshal.ThrowExceptionForHR(hr);

            // Make sure the value we set is what we just read
            Debug.Assert(Width1 + 1 == Width2, "Put/Get Width");
        }
示例#3
0
        public override void Init()
        {
            if (!isPlaying)
            {
                string Filename = "";
                float size = 0;
                double Max = 0;
                int volume = 0;

                graph = new FilterGraph() as IFilterGraph;
                media = graph as IMediaControl;
                eventEx = media as IMediaEventEx;
                igb = media as IGraphBuilder;
                imp = igb as IMediaPosition;
                master.form.Invoke((MethodInvoker)delegate()
                {
                    Filename = master.form.M_Filename.Text;
                    media.RenderFile(Filename);
                    size = (float)master.form.M_PrevSize.Value;
                    master.form.M_PrevSize.Enabled = false;
                    imp.get_Duration(out Max);
                    master.form.M_Seek.Maximum = (int)(Max);
                    master.form.M_Seek.Value = 0;
                    volume = master.form.M_Volume.Value;
                    span = (uint)(1000000.0f / master.form.M_CollectFPS);
                });
                graph.FindFilterByName("Video Renderer", out render);
                if (render != null)
                {
                    window = render as IVideoWindow;
                    window.put_WindowStyle(
                        WindowStyle.Caption | WindowStyle.Child
                        );
                    window.put_WindowStyleEx(
                        WindowStyleEx.ToolWindow
                        );
                    window.put_Caption("ElectronicBoard - VideoPrev -");

                    int Width, Height, Left, Top;
                    window.get_Width(out Width);
                    window.get_Height(out Height);
                    window.get_Left(out Left);
                    window.get_Top(out Top);
                    renderSize.Width = (int)(Width * size);
                    renderSize.Height = (int)(Height * size);
                    Aspect = (float)renderSize.Height / (float)renderSize.Width;
                    window.SetWindowPosition(Left, Top, renderSize.Width, renderSize.Height);

                    eventEx = media as IMediaEventEx;
                    eventEx.SetNotifyWindow(master.form.Handle, WM_DirectShow, IntPtr.Zero);
                    media.Run();
                    foreach (Process p in Process.GetProcesses())
                    {
                        if (p.MainWindowTitle == "ElectronicBoard - VideoPrev -")
                        {
                            renderwindow = p.MainWindowHandle;
                            break;
                        }
                    }
                    isPlaying = true;
                    iba = media as IBasicAudio;
                    iba.put_Volume(volume);

                    //master.form.checkBox3_CheckedChanged(null, null);
                    master.Start();
                }
            }
        }