////////////
        /// Get/Put WindowStyleEx
        private void TestWindowStyleEx()
        {
            int           hr;
            WindowStyleEx wsx1, wsx2;

            // Read the current WindowStyleEx
            hr = m_ivw.get_WindowStyleEx(out wsx1);
            Marshal.ThrowExceptionForHR(hr);

            // Flip the Layered bit
            wsx1 ^= WindowStyleEx.Layered;

            // Write the changed style
            hr = m_ivw.put_WindowStyleEx(wsx1);
            Marshal.ThrowExceptionForHR(hr);

            // Read the style
            hr = m_ivw.get_WindowStyleEx(out wsx2);
            Marshal.ThrowExceptionForHR(hr);

            // Make sure the value we set is what we just read
            Debug.Assert(wsx1 == wsx2, "Put/Get WindowStyleEx");
        }
Example #2
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();
                }
            }
        }
Example #3
0
        public void ReloadName()
        {
            try
            {
                if (basefilter == null)
                {
                    return;
                }
                FilterInfo fi;
                basefilter.QueryFilterInfo(out fi);
                name    = fi.achName;
                orgname = fi.achName;

                IFileSourceFilter fsrc = basefilter as IFileSourceFilter;
                if (fsrc != null && fsrc.GetCurFile(out srcfilename, null) == 0 && srcfilename != null && !name.Contains(srcfilename))
                {
                    name += " " + srcfilename.Substring(srcfilename.LastIndexOf('\\') + 1);
                }

                IFileSinkFilter fdst = basefilter as IFileSinkFilter;
                if (fdst != null && fdst.GetCurFile(out dstfilename, null) == 0 && dstfilename != null && !name.Contains(dstfilename))
                {
                    name += " " + dstfilename.Substring(dstfilename.LastIndexOf('\\') + 1);
                }

                string dspname = filterProps.DisplayName;
                if (dspname != null && dspname.Length > 0)
                {
                    if (!dispnames.ContainsKey(orgname))
                    {
                        dispnames.Add(orgname, dspname);
                    }
                }
                else //have no display name
                {
                    if (dispnames.TryGetValue(orgname, out dspname))
                    {
                        filterProps.DisplayName = dspname;
                    }
                }

                IVideoWindow vw = basefilter as IVideoWindow;
                if (vw != null)
                {
                    //string s;
                    //vw.get_Caption(out s);
                    string gname = Graph.Form.Text + ": " + name;// +": ";
                    vw.put_Caption(gname);
                    //vw.SetWindowForeground(OABool.False);
                    //vw.put_AutoShow(OABool.True);
                    //vw.put_Owner(Program.mainform.Handle); hangs
                    WindowStyleEx wex;
                    vw.get_WindowStyleEx(out wex);
                    vw.put_WindowStyleEx(wex | WindowStyleEx.Topmost);
                }
            }
            catch (COMException e)
            {
                Graph.ShowCOMException(e, "Problem occured while examining filter " + Name);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Exception caught while examining filter " + Name);
            }
        }
Example #4
0
        private void loadVideo(String videoPath)
        {
            videoFilepath = videoPath;
                videoFileName.Text = getDisplayVideoName();

                if (graph != null)
                {
                    graph = null;

                }
                if (mediaControl != null)
                {
                    // Stop media playback
                    this.mediaControl.Stop();
                    mediaControl = null;
                }

                if (videoWindow != null)
                {
                    videoWindow.put_Owner(IntPtr.Zero);
                    videoWindow = null;
                }

                if (mediaSeeking != null)
                {

                    mediaSeeking = null;
                }
                if (basicAudio != null)
                {

                    basicAudio = null;
                }
                GC.Collect();

               /* if (mediaPosition != null)
                {
                    mediaPosition = null;
                }*/

                graph = (IGraphBuilder)new FilterGraph();
                mediaControl = (IMediaControl)graph;
                //mediaPosition = (IMediaPosition)graph;
                videoWindow = (IVideoWindow)graph;
                mediaSeeking = (IMediaSeeking)graph;
                basicAudio = (IBasicAudio)graph;

                AviSplitter spliter = new AviSplitter();
                graph.AddFilter((IBaseFilter)spliter, null);
                graph.RenderFile(videoPath, null);
                graph.SetDefaultSyncSource();

                /*
                 * AMSeekingSeekingCapabilities cap = AMSeekingSeekingCapabilities.CanGetCurrentPos;
                if (mediaSeeking.CheckCapabilities(ref cap) > 0)
                {
                    this.consoleErreur.AppendText("Impossible de recuperer la position de la frame");
                }
                 * */

                videoWindow.put_Owner(videoPanel.Handle);

                videoWindow.put_MessageDrain(videoPanel.Handle);

                videoWindow.put_WindowStyle(WindowStyle.Child);
                videoWindow.put_WindowStyleEx(WindowStyleEx.ControlParent);
                videoWindow.put_Left(0);
                videoWindow.put_Top(0);
                videoWindow.put_Width(videoPanel.Width);
                videoWindow.put_Height(videoPanel.Height);

                //positionTrackbar.Enabled = true;
                speedTrackBar.Enabled = true;
                mediaSeeking.SetTimeFormat(TimeFormat.Frame);

                double rate;
                mediaSeeking.GetRate(out rate);
                rateText.Text = rate.ToString();
                speedTrackBar.Value = (int)(speedTrackBar.Maximum * rate / 2);

                trackBar1.Value = trackBar1.Maximum / 2;
                this.basicAudio.put_Volume(-5000 + 5000 * trackBar1.Value / trackBar1.Maximum);
            //mediaPosition.put_Rate(0.5);
                running = false;
                frameChanged = false;
        }